mirror of
				https://github.com/smarty-php/smarty.git
				synced 2025-11-03 22:01:36 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			295 lines
		
	
	
		
			6.4 KiB
		
	
	
	
		
			XML
		
	
	
	
	
	
			
		
		
	
	
			295 lines
		
	
	
		
			6.4 KiB
		
	
	
	
		
			XML
		
	
	
	
	
	
<?xml version="1.0" encoding="iso-8859-1"?>
 | 
						|
<!-- $Revision$ -->
 | 
						|
<sect1 id="language.function.textformat">
 | 
						|
 <title>{textformat}</title>
 | 
						|
  <para>
 | 
						|
   <varname>{textformat}</varname> is a
 | 
						|
   <link linkend="plugins.block.functions">block function</link>
 | 
						|
   used to format text. It basically  cleans up spaces and special characters,
 | 
						|
   and formats paragraphs by  wrapping at a boundary and indenting lines.
 | 
						|
  </para>
 | 
						|
  <para>
 | 
						|
   You can set the parameters explicitly, or use a preset style.
 | 
						|
   Currently <quote>email</quote> is the only available style.
 | 
						|
 </para>
 | 
						|
 | 
						|
 <informaltable frame="all">
 | 
						|
  <tgroup cols="5">
 | 
						|
   <colspec colname="param" align="center" />
 | 
						|
   <colspec colname="type" align="center" />
 | 
						|
   <colspec colname="required" align="center" />
 | 
						|
   <colspec colname="default" align="center" />
 | 
						|
   <colspec colname="desc" />
 | 
						|
   <thead>
 | 
						|
    <row>
 | 
						|
     <entry>Attribute Name</entry>
 | 
						|
     <entry>Type</entry>
 | 
						|
     <entry>Required</entry>
 | 
						|
     <entry>Default</entry>
 | 
						|
     <entry>Description</entry>
 | 
						|
    </row>
 | 
						|
   </thead>
 | 
						|
   <tbody>
 | 
						|
    <row>
 | 
						|
     <entry>style</entry>
 | 
						|
     <entry>string</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry><emphasis>n/a</emphasis></entry>
 | 
						|
     <entry>Preset style</entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>indent</entry>
 | 
						|
     <entry>number</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry><emphasis>0</emphasis></entry>
 | 
						|
     <entry>The number of chars to indent every line</entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>indent_first</entry>
 | 
						|
     <entry>number</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry><emphasis>0</emphasis></entry>
 | 
						|
     <entry>The number of chars to indent the first line</entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>indent_char</entry>
 | 
						|
     <entry>string</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry><emphasis>(single space)</emphasis></entry>
 | 
						|
     <entry>The character (or string of chars) to indent with</entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>wrap</entry>
 | 
						|
     <entry>number</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry><emphasis>80</emphasis></entry>
 | 
						|
     <entry>How many characters to wrap each line to</entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>wrap_char</entry>
 | 
						|
     <entry>string</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry><emphasis>\n</emphasis></entry>
 | 
						|
     <entry>The character (or string of chars) to break each line with</entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>wrap_cut</entry>
 | 
						|
     <entry>boolean</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry><emphasis>&false;</emphasis></entry>
 | 
						|
     <entry>If &true;, wrap will break the line at the exact
 | 
						|
      character instead of at a word boundary</entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>assign</entry>
 | 
						|
     <entry>string</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry><emphasis>n/a</emphasis></entry>
 | 
						|
     <entry>The template variable the output will be assigned to</entry>
 | 
						|
    </row>
 | 
						|
   </tbody>
 | 
						|
  </tgroup>
 | 
						|
 </informaltable>
 | 
						|
 | 
						|
 <example>
 | 
						|
  <title>{textformat}</title>
 | 
						|
  <programlisting>
 | 
						|
<![CDATA[
 | 
						|
   {textformat wrap=40}
 | 
						|
 | 
						|
   This is foo.
 | 
						|
   This is foo.
 | 
						|
   This is foo.
 | 
						|
   This is foo.
 | 
						|
   This is foo.
 | 
						|
   This is foo.
 | 
						|
 | 
						|
   This is bar.
 | 
						|
 | 
						|
   bar foo bar foo     foo.
 | 
						|
   bar foo bar foo     foo.
 | 
						|
   bar foo bar foo     foo.
 | 
						|
   bar foo bar foo     foo.
 | 
						|
   bar foo bar foo     foo.
 | 
						|
   bar foo bar foo     foo.
 | 
						|
   bar foo bar foo     foo.
 | 
						|
 | 
						|
   {/textformat}
 | 
						|
 | 
						|
]]>
 | 
						|
  </programlisting>
 | 
						|
  <para>
 | 
						|
   The above example will output:
 | 
						|
  </para>
 | 
						|
  <screen>
 | 
						|
<![CDATA[
 | 
						|
 | 
						|
   This is foo. This is foo. This is foo.
 | 
						|
   This is foo. This is foo. This is foo.
 | 
						|
 | 
						|
   This is bar.
 | 
						|
 | 
						|
   bar foo bar foo foo. bar foo bar foo
 | 
						|
   foo. bar foo bar foo foo. bar foo bar
 | 
						|
   foo foo. bar foo bar foo foo. bar foo
 | 
						|
   bar foo foo. bar foo bar foo foo.
 | 
						|
]]>
 | 
						|
  </screen>
 | 
						|
  <programlisting>
 | 
						|
<![CDATA[
 | 
						|
   {textformat wrap=40 indent=4}
 | 
						|
 | 
						|
   This is foo.
 | 
						|
   This is foo.
 | 
						|
   This is foo.
 | 
						|
   This is foo.
 | 
						|
   This is foo.
 | 
						|
   This is foo.
 | 
						|
 | 
						|
   This is bar.
 | 
						|
 | 
						|
   bar foo bar foo     foo.
 | 
						|
   bar foo bar foo     foo.
 | 
						|
   bar foo bar foo     foo.
 | 
						|
   bar foo bar foo     foo.
 | 
						|
   bar foo bar foo     foo.
 | 
						|
   bar foo bar foo     foo.
 | 
						|
   bar foo bar foo     foo.
 | 
						|
 | 
						|
   {/textformat}
 | 
						|
 | 
						|
]]>
 | 
						|
  </programlisting>
 | 
						|
  <para>
 | 
						|
   The above example will output:
 | 
						|
  </para>
 | 
						|
  <screen>
 | 
						|
<![CDATA[
 | 
						|
 | 
						|
   This is foo. This is foo. This is
 | 
						|
   foo. This is foo. This is foo. This
 | 
						|
   is foo.
 | 
						|
 | 
						|
   This is bar.
 | 
						|
 | 
						|
   bar foo bar foo foo. bar foo bar foo
 | 
						|
   foo. bar foo bar foo foo. bar foo
 | 
						|
   bar foo foo. bar foo bar foo foo.
 | 
						|
   bar foo bar foo foo. bar foo bar
 | 
						|
   foo foo.
 | 
						|
]]>
 | 
						|
  </screen>
 | 
						|
  <programlisting>
 | 
						|
<![CDATA[
 | 
						|
   {textformat wrap=40 indent=4 indent_first=4}
 | 
						|
 | 
						|
   This is foo.
 | 
						|
   This is foo.
 | 
						|
   This is foo.
 | 
						|
   This is foo.
 | 
						|
   This is foo.
 | 
						|
   This is foo.
 | 
						|
 | 
						|
   This is bar.
 | 
						|
 | 
						|
   bar foo bar foo     foo.
 | 
						|
   bar foo bar foo     foo.
 | 
						|
   bar foo bar foo     foo.
 | 
						|
   bar foo bar foo     foo.
 | 
						|
   bar foo bar foo     foo.
 | 
						|
   bar foo bar foo     foo.
 | 
						|
   bar foo bar foo     foo.
 | 
						|
 | 
						|
   {/textformat}
 | 
						|
]]>
 | 
						|
  </programlisting>
 | 
						|
  <para>
 | 
						|
   The above example will output:
 | 
						|
  </para>
 | 
						|
  <screen>
 | 
						|
<![CDATA[
 | 
						|
 | 
						|
   This is foo. This is foo. This
 | 
						|
   is foo. This is foo. This is foo.
 | 
						|
   This is foo.
 | 
						|
 | 
						|
   This is bar.
 | 
						|
 | 
						|
   bar foo bar foo foo. bar foo bar
 | 
						|
   foo foo. bar foo bar foo foo. bar
 | 
						|
   foo bar foo foo. bar foo bar foo
 | 
						|
   foo. bar foo bar foo foo. bar foo
 | 
						|
   bar foo foo.
 | 
						|
]]>
 | 
						|
  </screen>
 | 
						|
  <programlisting>
 | 
						|
<![CDATA[
 | 
						|
   {textformat style="email"}
 | 
						|
 | 
						|
   This is foo.
 | 
						|
   This is foo.
 | 
						|
   This is foo.
 | 
						|
   This is foo.
 | 
						|
   This is foo.
 | 
						|
   This is foo.
 | 
						|
 | 
						|
   This is bar.
 | 
						|
 | 
						|
   bar foo bar foo     foo.
 | 
						|
   bar foo bar foo     foo.
 | 
						|
   bar foo bar foo     foo.
 | 
						|
   bar foo bar foo     foo.
 | 
						|
   bar foo bar foo     foo.
 | 
						|
   bar foo bar foo     foo.
 | 
						|
   bar foo bar foo     foo.
 | 
						|
 | 
						|
   {/textformat}
 | 
						|
 | 
						|
]]>
 | 
						|
  </programlisting>
 | 
						|
  <para>
 | 
						|
   The above example will output:
 | 
						|
  </para>
 | 
						|
  <screen>
 | 
						|
<![CDATA[
 | 
						|
 | 
						|
   This is foo. This is foo. This is foo. This is foo. This is foo. This is
 | 
						|
   foo.
 | 
						|
 | 
						|
   This is bar.
 | 
						|
 | 
						|
   bar foo bar foo foo. bar foo bar foo foo. bar foo bar foo foo. bar foo
 | 
						|
   bar foo foo. bar foo bar foo foo. bar foo bar foo foo. bar foo bar foo
 | 
						|
   foo.
 | 
						|
 | 
						|
]]>
 | 
						|
  </screen>
 | 
						|
 </example>
 | 
						|
  <para>
 | 
						|
  See also
 | 
						|
  <link linkend="language.function.strip"><varname>{strip}</varname></link>
 | 
						|
  and
 | 
						|
  <link linkend="language.modifier.wordwrap"><varname>wordwrap</varname></link>.
 | 
						|
 </para>
 | 
						|
 | 
						|
</sect1>
 | 
						|
<!-- Keep this comment at the end of the file
 | 
						|
Local variables:
 | 
						|
mode: sgml
 | 
						|
sgml-omittag:t
 | 
						|
sgml-shorttag:t
 | 
						|
sgml-minimize-attributes:nil
 | 
						|
sgml-always-quote-attributes:t
 | 
						|
sgml-indent-step:1
 | 
						|
sgml-indent-data:t
 | 
						|
indent-tabs-mode:nil
 | 
						|
sgml-parent-document:nil
 | 
						|
sgml-default-dtd-file:"../../../../manual.ced"
 | 
						|
sgml-exposed-tags:nil
 | 
						|
sgml-local-catalogs:nil
 | 
						|
sgml-local-ecat-files:nil
 | 
						|
End:
 | 
						|
vim600: syn=xml fen fdm=syntax fdl=2 si
 | 
						|
vim: et tw=78 syn=sgml
 | 
						|
vi: ts=1 sw=1
 | 
						|
--> |