Really simple templates with ruby
Example:
template = 'Hello #{name}!'
name = 'Paul'
puts eval(%{"#{template}"}) # => Hello Paul!
name = 'Holger'
puts eval(%{"#{template}"}) # => Hello Holger!Note that the template definition use a single qutoed string, so no variables are evaluated within the template string.Also note that the template can't use unescaped double quotes, because the template evaluation uses them to delimit the template string.

0 Kommentare:
Kommentar veröffentlichen
Links zu diesem Post:
Link erstellen
<< Startseite