Skip to content

redding/sanford-nm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sanford::Nm

Sanford template engine for rendering Nm templates

Usage

Register the engine:

require 'sanford'
require 'sanford-nm'

Sanford.configure do |c|

  c.template_source "/path/to/templates" do |s|
    s.engine 'nm', Sanford::Nm::TemplateEngine
  end

end

Add .nm to any template files in your template source path. Sanford will render their content using Nm when they are rendered.

Notes

Nm doesn't allow overriding the template scope but instead allows you to pass in data that binds to the template scope as methods. By default, the service handler will be bound to Nm's scope via the view method in templates. If you want to change this, provide a 'handler_local' option when registering:

  c.template_source "/path/to/templates" do |s|
    s.engine 'nm', Sanford::Nm::TemplateEngine, 'handler_local' => 'service_handler'
  end

Nm doesn't cache templates by default. To enable caching, pass a 'cache' option when registering:

  c.template_source "/path/to/templates" do |s|
    s.engine 'nm', Sanford::Nm::TemplateEngine, 'cache' => true
  end

Installation

Add this line to your application's Gemfile:

gem 'sanford-nm'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sanford-nm

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request