Sha256: 79cd587d4375323c9ee179388a9ddb25fe2088e5ef26386348e7eb3de1ea9a2c
Contents?: true
Size: 856 Bytes
Versions: 1
Compression:
Stored size: 856 Bytes
Contents
require "tilt/erb" template = Tilt::ERBTemplate.new("templates/foo.erb") joe = Person.find("joe") template.render(joe, x: 35, y: 42) # If no scope is provided, the template is evaluated within the context of an object created with Object.new. # A single Template instance's render method may be called multiple times with different scope and locals arguments. Continuing the previous example, we render the same compiled template but this time in jane's scope: jane = Person.find("jane") template.render(jane, x: 22, y: nil) # Blocks can be passed to render for templates that support running arbitrary ruby code (usually with some form of yield). For instance, assuming the following in foo.erb: # Hey <%= yield %>! # The block passed to render is called on yield: template = Tilt::ERBTemplate.new("foo.erb") template.render { "Joe" } # => "Hey Joe!"
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
render_me_pretty-1.0.0 | tilt_examples.rb |