Module: Brief::Document::Rendering
- Extended by:
- ActiveSupport::Concern
- Included in:
- Brief::Document
- Defined in:
- lib/brief/document/rendering.rb
Defined Under Namespace
Modules: ClassMethods Classes: HeadingWrapper
Instance Method Summary collapse
-
#to_html(options = {}) ⇒ Object
Documents can be rendered into HTML.
- #unwrapped_html ⇒ Object
Instance Method Details
#to_html(options = {}) ⇒ Object
Documents can be rendered into HTML.
They will first be put through a Nokogiri processor pipeline which allows us to wrap things in section containers, apply data attributes, and other things to the HTML so that the output HTML retains its relationship to the underlying data and document structure.
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/brief/document/rendering.rb', line 39 def to_html( = {}) html = if [:wrap] == false unwrapped_html else wrapper = .fetch(:wrapper, 'div') "<#{ wrapper } data-brief-model='#{ model_class.type_alias }' data-brief-path='#{ relative_path_identifier }'>#{ unwrapped_html }</#{wrapper}>" end html.respond_to?(:html_safe) ? html.html_safe : html.to_s end |
#unwrapped_html ⇒ Object
50 51 52 |
# File 'lib/brief/document/rendering.rb', line 50 def unwrapped_html parser.to_html end |