Project

weblet

0.0
The project is in a healthy, maintained state
Intended for retrieving HTML templates from a convenient to use Hash-like object.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
 Project Readme

Weblet: Content is now enclosed within a CDATA element

require 'weblet'

s3 = %q(
#fun
<p>hut</p>

#good
<p>star #{s2}</p>

#saturday
It's sunny!

#svg
  #reply

<svg>
i like that #{s2}
</svg>

  #favorite
<p>231</p>
)


s2 = 'tree'

w = Weblet.new(s3, binding, debug: true)

puts w.render('svg/reply') #=> <svg>\n  i like that tree ...
puts w.render(:saturday)   #=> It's sunny!  
puts w.render(:reply)      #=> <svg>\n  i like that tree ...

puts w.to_xml

Output:

<weblet>
  <node id='fun'><![CDATA[<p>hut</p>]]></node>
  <node id='good'><![CDATA[<p>star #{s2}</p>]]></node>
  <node id='saturday'><![CDATA[It's sunny!]]></node>
  <node id='svg'>
    <node id='reply'><![CDATA[<svg>
i like that #{s2}
</svg>]]></node>
    <node id='favorite'><![CDATA[<p>231</p>]]></node>
  </node>
</weblet>

weblet


Introducing the Weblet gem

require 'weblet'

s3 = %q(
#fun
<p>hut</p>

#good
<p>star #{s2}</p>

#svg
  #reply

<svg>
i like that #{s2}
</svg>

  #favorite
<p>231</p>
)


s2 = 'tree'

w = Weblet.new(s3, binding)
puts w.render('svg/reply')

Output:

<svg>
i like that tree
</svg>

A slim-like template is used to store the HTML templates which are used by the Weblet gem to render the output.

Resources

weblet template html builder weblit weblets weblits