Class: ZTK::Template
- Inherits:
-
Object
- Object
- ZTK::Template
- Defined in:
- lib/ztk/template.rb
Overview
Erubis Templating Class
Given a template like this (i.e. "template.erb"):
This is a test template!
<%= @variable %>
We can do this:
ZTK::Template.render("template.erb", { :variable => "Hello World" })
And get:
This is a test template!
Hello World
Class Method Summary (collapse)
-
+ (String) do_not_edit_notice(options = {})
Renders a "DO NOT EDIT" notice for placement in generated files.
-
+ (String) render(template, context = nil)
Renders a template to a string.
-
+ (String) string(template, context = nil)
Renders a string to a string.
Class Method Details
+ (String) do_not_edit_notice(options = {})
Renders a "DO NOT EDIT" notice for placement in generated files.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/ztk/template.rb', line 58 def do_not_edit_notice(={}) = [:message] char = ([:char] || '#') notice = Array.new notice << char notice << "#{char} WARNING: AUTOMATICALLY GENERATED FILE; DO NOT EDIT!" if !.nil? notice << char notice << "#{char} #{}" end notice << char notice << "#{char} Generated @ #{Time.now.utc}" notice << char notice.join("\n") + "\n" end |
+ (String) render(template, context = nil)
Renders a template to a string.
37 38 39 |
# File 'lib/ztk/template.rb', line 37 def render(template, context=nil) render_template(load_template(template), context) end |
+ (String) string(template, context = nil)
Renders a string to a string.
47 48 49 |
# File 'lib/ztk/template.rb', line 47 def string(template, context=nil) render_template(template, context) end |