-
Notifications
You must be signed in to change notification settings - Fork 7
String Escaping
isaiah edited this page Oct 21, 2015
·
2 revisions
Stacks provides access to the RapidWeaver string escaping API. You can specify a specific string escaping format whenever you template replace a string from an "input" control (a text box).
NB: The specific behavior of these encodings is controlled by Rapidweaver, not Stacks. For more info see the NSString+RMKit.h header file in the RMKit framework
- Javascript ( -encodeJS ) — Encoded for use inside a single-quoted string.
- PHP ( -encodePHP ) — Encoded for use inside a single-quoted string.
- HTML (-encodeHTML ) — Encoded for display on an HTML page (markup characters are hexadecimal encoded).
- HTML Attribute ( -encodeHTMLAttribute ) — Encoded for use inside a double quoted HTML attribute (e.g. target="blank).
- XML ( -encodeXML ) — Encoded for use inside XML strings.
- Filename (-encodeFilename ) — Encoded for use as a file name on most filesystems.
If this code is used inside a template:
<br>text (default): %id=textInput%<br>
<br>text (JS): %id=textInput -encodeJS%<br>
<br>text (PHP): %id=textInput -encodePHP%<br>
<br>text (HTML): %id=textInput -encodeHTML%<br>
<br>text (Attribute): %id=textInput -encodeHTMLAttribute%<br>
<br>text (XML): %id=textInput -encodeXML%<br>
<br>text (Filename): %id=textInput -encodeFile%<br>
This output will be produced:
<br>text (default): this is a test " ' < > $<br>
<br>text (JS): this is a test " \' < > $<br>
<br>text (PHP): this is a test " \' < > $<br>
<br>text (HTML): this is a test " ' < > $<br>
<br>text (Attribute): this is a test " ' < > $<br>
<br>text (XML): this is a test " ' < > $<br>
<br>text (Filename): this-is-a-test-0022-0027-003C-003E-0024<br>