Class: Rag::Template
- Inherits:
-
Object
- Object
- Rag::Template
- Defined in:
- lib/rag/new.rb
Constant Summary collapse
Instance Attribute Summary collapse
-
#source_root ⇒ Object
readonly
Returns the value of attribute source_root.
Class Method Summary collapse
Instance Method Summary collapse
- #have_ext(ext) ⇒ Object
-
#initialize(o = {}) ⇒ Template
constructor
A new instance of Template.
-
#locals ⇒ Object
for tilt.
-
#render(path) ⇒ Object
path absolute or relative.
Constructor Details
#initialize(o = {}) ⇒ Template
Returns a new instance of Template.
143 144 145 |
# File 'lib/rag/new.rb', line 143 def initialize(o={}) @source_root = o[:source_root] || "" end |
Instance Attribute Details
#source_root ⇒ Object (readonly)
Returns the value of attribute source_root.
139 140 141 |
# File 'lib/rag/new.rb', line 139 def source_root @source_root end |
Class Method Details
Instance Method Details
#have_ext(ext) ⇒ Object
155 156 157 |
# File 'lib/rag/new.rb', line 155 def have_ext(ext) Rc.exts.include? ext end |
#render(path) ⇒ Object
path absolute or relative.
148 149 150 151 152 153 |
# File 'lib/rag/new.rb', line 148 def render(path) path = Pa(Pa.absolute?(path) ? path : Pa.join(source_root, path)) path = path.build(fname: (path.base[0]=="_" ? "" : "_")+path.base) Tilt::ERBTemplate.new(path.p).render(self, locals) end |