Module: Tiny::Helpers
- Includes:
- Buffering, ErubisTemplating, HamlTemplating, Markup
- Included in:
- Rendering
- Defined in:
- lib/tiny.rb
Overview
Include this module anywhere you want to use markup generation, or define view helpers using Tiny.
Class Method Summary collapse
- .escape_html(html) ⇒ Object
-
.sanitize(value) ⇒ String
HTML-escapes the passed value unless the content is considered safe (html_safe? is implemented and returns true).
Instance Method Summary collapse
Methods included from HamlTemplating
Methods included from Markup
#cdata, #comment, #doctype, #html_tag
Methods included from Buffering
#append, #append!, #raw, #with_buffer
Methods included from ErubisTemplating
#capture_erb, #erb_block?, #with_buffer
Class Method Details
.escape_html(html) ⇒ Object
360 361 362 |
# File 'lib/tiny.rb', line 360 def self.escape_html(html) CGI.escapeHTML html.to_s end |
.sanitize(value) ⇒ String
HTML-escapes the passed value unless the content is considered safe (html_safe? is implemented and returns true)
352 353 354 355 356 357 358 |
# File 'lib/tiny.rb', line 352 def self.sanitize(value) if value.respond_to?(:html_safe?) && value.html_safe? value.to_s else escape_html value.to_s end end |
Instance Method Details
#tag(name, attrs_or_content = {}, attrs = nil, &block) ⇒ String
Alias for Markup#html_tag
341 342 343 |
# File 'lib/tiny.rb', line 341 def tag(name, attrs_or_content = {}, attrs = nil, &block) html_tag name, attrs_or_content, attrs, &block end |