https://github.com/redding/sanford-nm
Sanford template engine for Nm templates
https://github.com/redding/sanford-nm
ruby template-engine
Last synced: about 1 year ago
JSON representation
Sanford template engine for Nm templates
- Host: GitHub
- URL: https://github.com/redding/sanford-nm
- Owner: redding
- License: mit
- Created: 2014-06-08T22:10:50.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2017-08-17T15:41:08.000Z (almost 9 years ago)
- Last Synced: 2025-03-17T05:46:59.965Z (over 1 year ago)
- Topics: ruby, template-engine
- Language: Ruby
- Size: 22.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Sanford::Nm
[Sanford](https://github.com/redding/sanford) template engine for rendering [Nm](https://github.com/redding/nm) templates
## Usage
Register the engine:
```ruby
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:
```ruby
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:
```ruby
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