bldr
bldr copied to clipboard
Minimalist JSON templating DSL.
This behavior should be over-rideable. The default should be iso8601, but we should provide a way for people to render time objects as unix timestamps as well.
A common use case is rendering a model's json when "bootstrapping" an html page so javascript classes / views can make use of the model data: ``` erb App.person =...
Currently the Rails lookup path is not supported, so you have to specify the full path to the template like so: ``` ruby object(@person) do template "app/views/people/_person" end ``` You...
Example ``` ruby get '/hello' do user = User.some_lookup_method(params['id]) bldr :'template', :locals => {:user => user, :raw_value => rand(10)} end # template.bldr object :user => user do attribute :raw_value =>...
This _may_ be due to weirdness with sinatra respond to taking over exception handling....
The line number frequently is off by two to the nearest seemingly matching line. ``` app/views/api/account/show.json.bldr:31:in `block (4 levels) in singletonclass' [GEM_ROOT]/gems/bldr-0.5.3/lib/bldr/node.rb:158:in `instance_eval' [GEM_ROOT]/gems/bldr-0.5.3/lib/bldr/node.rb:158:in `attribute' app/views/api/account/show.json.bldr:31:in `block (3 levels) in...
Often times, when an attribute has a nil/null value, we don't want to include the key at all in response. An option to the `attribute` method like `:include_blank => false`...