escaper

toc
<mm:escaper> You can defined 'parameterized' escapers by this. (since: MMBase-1.8)
see alsocontent
attributes
  • id
    By the id the escaper is available.
  • referid
    Reuses the escaper identified by this.
  • type
    What kind of escaper.
    Parameterized EscaperParameters
    regexps Regexp-replacing.
    Parameter nameDescription
    patterns A list of entries describing regular expresions replacements. Replacements happens per word.
    wrap Word wrapping. Works on plain/text, and wraps with newlines. Can be converted to HTML with a chained escaper.
    Parameter nameDescription
    length Length of lines (default to 80).
    substring Take substring.
    Parameter nameDescription
    from
    to
    ellipsis Can be used to put those three dots ('...') at the end of a 'substringed' line.
    paragraphWraps a text in paragraph (p) tags, unless it is empty or that textstarts with a p tag (in which case it is already wrapped). Use this for fields that contain HTML, but for which you are unsure if they have parahraph tags already
    Parameter nameDescription
    class A class name to give to the paragraph tag.
    resourcebundle Replaces the words which are present as key in given resourcebundle with the values. Since resource bundles are localized, this gives a way to translate (mm:write is nearly fmt:message). E.g. mm:write escape="resourcebundle(org.mmbase.datatypes.resources.ordinals)" value="5".
    Parameter nameDescription
    basename
    mode
    locale
    ordinals Replaces numerics with ordinals ('first', 'second'...).
    Parameter nameDescription
    basename
    mode
    locale
    google Explores the request for the 'referer' http header. If this is from google, the google search words are highlighted in the text.
    Parameter nameDescription
    encryption Encrypts or decrypts the given input using a cryptographic algorithm that is specified as a parameter.
    Parameter nameDescription
    key The key used to encrypt the data. eg. AES uses a 128 bit key.
    format The in-/output format of the ecrypted data. 'hex'(default) or 'base64'
    algorithm The algorithm used for the encryption. eg. 'AES'(default), 'DES', 'Blowfish', etc.
    direction The direction of encryption. 'encrypt'(default) or 'decrypt'
    codesample

    Escapes the code between the tags you define.

    This escaper enables the use of two different escapers in one piece of text. It was started to simplify the inclusion of a code snippet in html but can be used for other purposes as well.

    You can specify the tags between which you wish to escape your text, the escaper to use and you can set an escaper for the rest of the text. It needs to be rewritten to support all escapers/transformers. It only supports the escapers p, pp, p-ommit-surrounding, pp-ommit-surrounding, inline, text/html and text/xml for now. All parameters may be ommitted then it defaults to <pre> and 'text/html'. Use it like f.e.:

    <mm:import id="texttext"> This is an example: <% String foo = "bar"; %> </mm:import> <mm:escaper type="codesample" id="testsample" /> <mm:write referid="testtext" escape="testsample" />

    Parameter nameDescription
    starttag The starttag, f.e. <pre>.
    closetag The closetag, f.e. </pre>.
    escapecode The escaper to use between the start- and closetag.
    escaperest The escaper to use on the rest of the text.
    tagstripper

    Changes existing HTML markup.

    Parameter nameDescription
    tags Either XSS or NONE. XSS will strip all tags and attributes which may have been present in the HTML to try cross-site-scripting. NONE will strip all tags, and produce plain text.
    addbrs If true, then newlines are replaced by br-tags. This can be used to make better html from a kind of pseudo-html.
    escapeamps Html 4 entities are resolved. This indicated whether the remaining ampersands must be replaced with &amp;. Default to false. But see also the 'toxml' escaper.
    toxml

    This filters HTML-4, and cleanes it up, so that it is valid XML. At the moment, like tagstrippers(XSS), with escapeamps is true.

    Parameter nameDescription
    tags
    addbrs
    escapeamps

  • inverse
    Turns the escaper arround (so, will call the 'transformBack' methods).
example 1
<mm:escaper id="vervang"><!-- define a new 'escaper' which is a combination of 3 other escapers -->
  <mm:escaper type="regexps">
    <mm:param name="patterns"><!-- the regexps type escapers need a parameter named 'patterns' -->
      <!-- this parameter must be a list of name-value's. We can simply use sub-param-tags for that -->
      <mm:param name="aaa" value="bbb" />
      <mm:param name="ccc" value="ddd" />
    </mm:param>
  </mm:escaper>
  <mm:escaper referid="uppercase" /> <!-- simply reuse an existing one here -->
  <mm:escaper type="substring">
     <mm:param name="from" value="2" />
  </mm:escaper>
</mm:escaper>
<p>
  <mm:write value="aba aaa b ccc " escape="vervang" /><!-- will write A BBB B DDD -->
</p>