Skip to content

Added 5 escaper methods for manual escaping

Compare
Choose a tag to compare
@rotexdegba rotexdegba released this 25 Apr 18:58
· 127 commits to master since this release

Added 5 escaper methods to the Renderer Class:

  • $this->escapeHtml(string $some_string_variable): an alias for PHP's htmlspecialchars() for escaping data which may contain html markup.
  • $this->escapeHtmlAttr(string $some_string_variable): for escaping data which is meant to be rendered as an attribute value within an html element in a view.
  • $this->escapeCss(string $some_string_variable): for escaping data which is meant to be rendered within <style> tags or inside the style attribute of any html element.
  • $this->escapeJs(string $some_string_variable): for escaping data which is meant to be rendered as string literals or digits within Javascript code in a view.
  • $this->escapeUrl(string $some_string_variable): an alias for PHP's rawurlencode() for escaping data being inserted into a URL and not to the whole URL itself.

These methods can be called directly within views.

Also added __toString() which calls renderToString with no args.