Reference - PAD functions - escape


App: manual - Page: fragments/pipes_5
PHP
fragments/pipes_5.php
HTML
fragments/pipes_5.pad
Result
<?php

$intro
= 'The quick brown fox jumps over the lazy dog, twice before breakfast';
$title = 'Crème Brûlée & Co.';
$size = 3221225472;
$quote = 'it\'s </script>';

?>
<p>{$intro | truncate(30)}</p>
<p>?page={$title | slug}</p>
<p>{$size | bytes}</p>
<p>{$quote | escape('js')}</p>


App: regression/framework - Page: escaping/a_quote_stand_in_from_the_request_is_escaped_as_the_quote
PHP
escaping/a_quote_stand_in_from_the_request_is_escaped_as_the_quote.php
HTML
escaping/a_quote_stand_in_from_the_request_is_escaped_as_the_quote.pad
Result
<?php

// A value as a request brings it: U+E022 and U+E027 are the stand-ins of the two quotes
// and U+E05C the one of the backslash (lib/encoding.php), which exits.php turns back into
// the characters as the page is written out - after every escaper has run.

$name = "x\u{E022} on=\u{E027}y\u{E05C}";

?>
<a title="{$name}">
{echo $name | html}
{$name | escape}
{echo $name | escape('attr')}
'{echo $name | slashes}'
<a data-p="{^name}">


App: regression/framework - Page: functions/a_field_inside_a_quoted_literal_reaches_a_pipe_as_its_characters
PHP
functions/a_field_inside_a_quoted_literal_reaches_a_pipe_as_its_characters.php
HTML
functions/a_field_inside_a_quoted_literal_reaches_a_pipe_as_its_characters.pad
Result
<?php

$subject
= 'Order 12, shipped';

?>
1[{echo 'Re: {$subject}' | url}] 2[{echo 'Re: {$subject}' | contains(',')}] 3[{echo 'Re: {$subject}' | replace(', ', ' - ')}] 4[{echo 'Re: {$subject}' | after(',')}] 5[{echo 'Re: {$subject}' | escape('js')}]


App: regression/framework - Page: functions/escape_writes_a_value_for_its_context
PHP
HTML
functions/escape_writes_a_value_for_its_context.pad
Result
[{echo 'a"b<c>' | escape}][{echo 'a b"<' | escape('attr')}][{echo 'it\'s </script> é' | escape('js')}][{echo 'a b;' | escape('css')}][{echo 'a/b c' | escape('url')}]


App: regression/framework - Page: lenient/a_list_handed_to_a_pipe_function_as_its_parameter_is_empty
PHP
lenient/a_list_handed_to_a_pipe_function_as_its_parameter_is_empty.php
HTML
lenient/a_list_handed_to_a_pipe_function_as_its_parameter_is_empty.pad
Result
<?php

// The lenient walk: a list where a pipe function wants a value as its parameter is empty.

$padCheckSyntax = FALSE;

?>
1[{echo 'abc' | contains(['a'])}] 2[{echo 'abc' like ['a']}] 3[{echo 'abc' | matches(['a'])}] 4[{echo 'abc' | after(['a'])}] 5[{echo 'abc' | left([1])}] 6[{echo 'abc' | truncate([2])}] 7[{echo 'abc' | escape(['js'])}] 8[{echo 'b' | between(['a'], 'z')}]