Nm
JSON/BSON data structure template system. Named for its two template methods: "node" and "map".
Usage
Template:
# in views/slideshow.json.nm
node 'slideshow' do
node 'start_slide',
node 'slides' do
map do ||
node 'id', .id
node 'title', .title
node 'image', .image_url
node 'thumb', .thumb_url
node 'url', .url
end
end
end
Output:
{ "slideshow": {
"start_slide": 1,
"slides": [
{ "id": "slide-1",
"title": "Slide 1",
"thumb": "//path/to/slide-1-thumb.jpg",
"image": "//path/to/slide-1-image.jpg",
"url": "//path/to/slide-1-url",
},
{ "id": "slide-2",
"title": "Slide 2",
"thumb": "//path/to/slide-2-thumb.jpg",
"image": "//path/to/slide-2-image.jpg",
"url": "//path/to/slide-2-url",
},
{ "id": "slide-3",
"title": "Slide 3",
"thumb": "//path/to/slide-3-thumb.jpg",
"image": "//path/to/slide-3-image.jpg",
"url": "//path/to/slide-3-url",
}
]
}
}
Installation
Add this line to your application's Gemfile:
gem 'nm'
And then execute:
$ bundle
Or install it yourself as:
$ gem install nm
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Added some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request