Skip to content

Instantly share code, notes, and snippets.

@tizoc
Created April 2, 2011 23:55
Show Gist options
  • Save tizoc/900026 to your computer and use it in GitHub Desktop.
Save tizoc/900026 to your computer and use it in GitHub Desktop.
Tpl.new("Testing loops: <% 3.times do %> * <% end %>")
# =>
def self.render(__v = {}, __o = '')
__o.concat("Testing loops: ")
3.times do
__o.concat(" * ")
end
__o
end
Tpl.new("The sum is <%=2+2%> Also substitute <%=myfield%> ok", %w(myfield))
# =>
def self.render(__v = {}, __o = '')
myfield = __v[:myfield]
__o.concat("The sum is ")
__r = (2+2).to_s
__o.concat(__r)
__o.concat(" Also substitute ")
__r = (myfield).to_s
__o.concat(__r)
__o.concat(" ok")
__o
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment