VI. Appendices

[ Previous: C. Content Classes | Next: E. Common Rule Examples ]

D. Template Flags

With an enhanced mode tag or the FillTemplate() function, you may add formatting flags to a variable after a slash character (/) to control how its text is cleaned up. By default, the text is unchanged, passed raw to the output. (Note: This differs from the behavior of NBBC v1.2 and earlier.) However, you can change this so that you do not have to manually encode your data: For example, using {$variable/u} instead of just {$variable} causes this variable to be passed through urlencode(), and using {$variable/e} causes this variable to be passed through HTMLEncode(). The available formatting flags are:

  • v - Verbatim. Do not apply any formatting to the variable; use its exact text, however the user provided it. This overrides all other flags.
  • b - Apply basename() to the variable.
  • n - Apply nl2br() to the variable.
  • t - Trim. This causes all initial and trailing whitespace to be trimmed (removed).
  • w - Clean up whitespace. This causes all non-newline whitespace, such as control codes and tabs, to be collapsed into individual space characters.
  • e - Apply BBCode::HTMLEncode() to the variable.
  • h - Apply htmlspecialchars() to the variable.
  • k - Apply BBCode::Wikify() to the variable.
  • u - Apply urlencode() to the variable.

Note that only one of the 'e', 'h', 'k', or 'u' flags may be specified; these four flags are mutually-exclusive. Note also that the 'v' flag overrides all other flags, and can effectively be used during debugging to temporarily disable all formatting flags.

[ Previous: C. Content Classes | Next: E. Common Rule Examples ]

Copyright © 2010, the Phantom Inker. All rights reserved.