Module: Philiprehberger::HtmlBuilder
- Defined in:
- lib/philiprehberger/html_builder.rb,
lib/philiprehberger/html_builder/node.rb,
lib/philiprehberger/html_builder/escape.rb,
lib/philiprehberger/html_builder/builder.rb,
lib/philiprehberger/html_builder/version.rb
Defined Under Namespace
Modules: Escape Classes: Builder, Error, Node, RawNode
Constant Summary collapse
- VERSION =
'0.4.0'
Class Method Summary collapse
-
.build {|Builder| ... } ⇒ String
Build HTML using a tag DSL (minified output).
-
.build_minified {|Builder| ... } ⇒ String
Build minified HTML (alias for build).
-
.build_pretty(indent_size: 2) {|Builder| ... } ⇒ String
Build pretty-printed HTML using a tag DSL.
-
.escape(value) ⇒ String
Escape HTML special characters in a string using the same escaper as the DSL.
-
.merge(*fragments) ⇒ String
Merge multiple HTML fragment strings into one.
Class Method Details
.build {|Builder| ... } ⇒ String
Build HTML using a tag DSL (minified output)
17 18 19 20 21 22 23 |
# File 'lib/philiprehberger/html_builder.rb', line 17 def self.build(&block) raise Error, 'a block is required' unless block builder = Builder.new builder.instance_eval(&block) builder.to_html end |
.build_minified {|Builder| ... } ⇒ String
Build minified HTML (alias for build)
44 45 46 |
# File 'lib/philiprehberger/html_builder.rb', line 44 def self.build_minified(&) build(&) end |
.build_pretty(indent_size: 2) {|Builder| ... } ⇒ String
Build pretty-printed HTML using a tag DSL
31 32 33 34 35 36 37 |
# File 'lib/philiprehberger/html_builder.rb', line 31 def self.build_pretty(indent_size: 2, &block) raise Error, 'a block is required' unless block builder = Builder.new builder.instance_eval(&block) builder.to_pretty_html(indent_size: indent_size) end |
.escape(value) ⇒ String
Escape HTML special characters in a string using the same escaper as the DSL.
60 61 62 |
# File 'lib/philiprehberger/html_builder.rb', line 60 def self.escape(value) Escape.html(value) end |
.merge(*fragments) ⇒ String
Merge multiple HTML fragment strings into one
52 53 54 |
# File 'lib/philiprehberger/html_builder.rb', line 52 def self.merge(*fragments) fragments.join end |