allow renderer to be provided

This commit is contained in:
leaf corcoran
2014-02-06 19:58:58 -08:00
parent 513f0ef39c
commit f39251eaf7
2 changed files with 11 additions and 9 deletions

View File

@@ -69,7 +69,6 @@ class Renderer
@push "_b[_b_i] = ", ...
@push "\n" if ...
class Parser
open_tag: "<%"
close_tag: "%>"
@@ -230,14 +229,14 @@ class Parser
setfenv fn, combined_env
fn buffer, #buffer, tostring, concat, html_escape
compile_to_lua: (str) =>
compile_to_lua: (str, ...) =>
success, err = @parse str
return nil, err unless success
@chunks_to_lua!
@chunks_to_lua ...
-- generates the code of the template
chunks_to_lua: =>
r = Renderer!
chunks_to_lua: (renderer_cls=Renderer) =>
r = renderer_cls!
r\header!
for chunk in *@chunks