This pull request brings Jbuilder, a Ruby DSL for structuring JSONs, into Geolexica.
Templating JSONs with Liquid is a poor idea for many reasons. Templates are difficult to read, it's easy to introduce errors, processing them is slow. Switching to Jbuilder solves all these problems.
A brand new {% jbuilder %} Liquid block tag is introduced. Content between that and a corresponding closing tag is captured and evaluated as a piece of Jbuilder-powered Ruby script, then a resulting JSON is rendered in place of that block. Rendering context (including page's front matter) is exposed through a getter. Because JSON-building Ruby script is still enclosed in a template, it's easy to override it in particular sites if needed.
All the JSONs defined in this gem have been rewritten in a Jbuilder fashion. JSONs defined in sites require separate treatment.
A side benefit is that sites generate noticeably faster (up to 30% as observed on my computer).
This pull request brings Jbuilder, a Ruby DSL for structuring JSONs, into Geolexica.
Templating JSONs with Liquid is a poor idea for many reasons. Templates are difficult to read, it's easy to introduce errors, processing them is slow. Switching to Jbuilder solves all these problems.
A brand new
{% jbuilder %}
Liquid block tag is introduced. Content between that and a corresponding closing tag is captured and evaluated as a piece of Jbuilder-powered Ruby script, then a resulting JSON is rendered in place of that block. Rendering context (including page's front matter) is exposed through a getter. Because JSON-building Ruby script is still enclosed in a template, it's easy to override it in particular sites if needed.All the JSONs defined in this gem have been rewritten in a Jbuilder fashion. JSONs defined in sites require separate treatment.
A side benefit is that sites generate noticeably faster (up to 30% as observed on my computer).