Sha256: 32fc0cb440fe8f160906e005e025d4ccd9df5baec1e610a0972ffe966a76c5ac
Contents?: true
Size: 999 Bytes
Versions: 1
Compression:
Stored size: 999 Bytes
Contents
require 'ragtag' template = %q{ <html> <body> <div attr="class: customer_class"> <h1 content="customer.name">John Doe</h1> <p>The customer is <span replace="customer.age" /> year old.</p> <ul each="customer.tags" do="tag"> <li content="tag">Tag</li> </ul> <ul each="customer.tags" do="tag"> <li each="tag.split(//)" do="x"> <b content="x" /> </li> </ul> <b class="notice" if="customer.age > 60"> The customer is a senior citizen. </b> <div class="notice" if="customer.age > 60" omit="true"> The customer is a senior citizen. </div> </div> </body> </html> } require 'ostruct' customer = OpenStruct.new customer.name = "John Roberts" customer.address = "555 Hobart St" customer.city = "Palm Bay" customer.state = "FL" customer.zip = "32709" customer.age = 65 customer.tags = [ 'ruby', 'javascript' ] customer_class = customer.age > 60 ? 'senior' : 'normal' xml = RagTag.compile(template, binding) puts xml
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ragtag-0.6.0 | eg/example.rb |