Sha256: e3e7a1c33473fb2e16c964d9618235044a9912378f4e9645aac4e565b0cb961c
Contents?: true
Size: 1.42 KB
Versions: 1
Compression:
Stored size: 1.42 KB
Contents
= Example Neapolitan Document Here is an example neapolitan file, 'example.choc': extension: html --- rdoc erb = Yummy Vanilla Hi <%= name %>, I know you want some of that yummy stuff. --- coderay.ruby %{S t r a w b e r r y}.each do |letter| puts "Give me a #{letter}!" end puts "What's that spell?" --- html liquid <quote> {{ yield }} </quote> --- textile | | 2009 | 2010 | | Has Choclate? | No | Yes! | --- markdown As you can see. It's all _fun_ and _games_ here. = Loading the Library Require the library. require 'neapolitan' = Reading a Neapolitan File Load our example template[fixtures/example.npt]. file = "qed/fixtures/example.npt" document = Neapolitan::Document.new(file) = Rendering Data Sources Neapolitan uses Malt on the backend. Malt supports a three separate ways to pass data into a template. The most obvious data source is a Hash. data = {:name=>"Tom"} text = document.render(data).to_s text.assert =~ /Hi Tom/ Templates can also be rendered given a Binding. name = "Huck" text = document.render(binding).to_s text.assert =~ /Hi Huck/ And lastly, they can be renderedwith the scope of any other type of Object, including an instance of a Struct. scope = Struct.new(:name).new("Becky") text = document.render(scope).to_s text.assert =~ /Hi Becky/
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
neapolitan-0.2.0 | qed/overview.rdoc |