Class: Ucode::Audit::Browser::Template
- Inherits:
-
Object
- Object
- Ucode::Audit::Browser::Template
- Defined in:
- lib/ucode/audit/browser/template.rb
Overview
Minimal ERB wrapper for the browser templates.
Reads an .erb template plus its sibling .css and .js
assets from TEMPLATE_DIR, renders them with the
supplied binding, and returns a complete HTML document.
Templates are plain ERB — no partials, no layouts, no helpers beyond what the binding provides. The CSS/JS assets are inlined into the rendered HTML so the page is fully self-contained (no external requests).
Instance Method Summary collapse
-
#initialize(name) ⇒ Template
constructor
A new instance of Template.
-
#render(locals = {}) ⇒ String
Rendered HTML.
Constructor Details
#initialize(name) ⇒ Template
Returns a new instance of Template.
24 25 26 |
# File 'lib/ucode/audit/browser/template.rb', line 24 def initialize(name) @name = name end |
Instance Method Details
#render(locals = {}) ⇒ String
Returns rendered HTML.
31 32 33 34 35 36 37 |
# File 'lib/ucode/audit/browser/template.rb', line 31 def render(locals = {}) erb = ERB.new(read("#{@name}.html.erb"), trim_mode: "-") erb.result_with_hash(locals.merge( _css: read("#{@name}.css"), _js: read("#{@name}.js"), )) end |