This is a general purpose and re-usable environment for creating Handlebars templates for the GetLocal platform.
You should receive access to design comps and a JSON data file.
- Clone this project
- Run
npm i
to install all necessary dependencies. - Run
gulp
to start the browser-sync and nodemon processes. - A browser should open and display the example site.
- Review how the templating system and helpers work.
- Name the JSON data file
pages.json
and place it in the./data/
directory. - Review the
pages.json
data for which pages will be available based on the definedurl
values. - The browser will automatically reload when changes are detected.
- The process may error due to the data no longer matching the markup.
- Implement the HBS (HTML), CSS, and JS necessary to match the design comps.
- Remove all unused default template files, scripts, and CSS.
- Validate the rendered HTML using validator.w3.org.
- Package the deliverables based on the
Asset Delivery
section below.
For comprehension, future proofing, and maintainability, please follow the following best practices.
- Use
/assets/dist/
as the base for media references. - Use the
{{#articleBody}}
helper to avoid hard coding numbers in variables (unless in{{#if}}
helpers). - Attempt to only use partials to coordinate with comp modules.
- Do not nest partials if the template allows.
- Use 2 spaces for indentation.
- Consistently dash-case name partials.
- Name partials after comp variable groups where possible. a. Place variable group references in the name first, so similar partials are grouped on the filesystem.
- Avoid hard coding any user visible text (expect variables).
- Utilize triple brackets for all articleBody driven output, except in HTML attributes.
- Do not duplicate content for responsive, unless responsive variables are provided.
The pages.json
should represent an array of objects.
Each object should have a url
property that defines the development URL the page will be viewable at.
The potentialAction
property of each object should be an array of objects.
The object with a name
property set to "renderHTML" will have an assembly
property that defines which file in the /templates/
folder will be used for rendering the page.
All user visible text content on GetLocal sites is intended to be driven via data. In other words, no user visible text should be hard coded in templates.
The variable names for each section of text is defined via the layer names of the design comps. There are a few conventions that those layer names should follow:
- Layer names ending with
-#
indicate a repeating element or list. - Layer names ending with
-#-#
indicate nested repeating elements, such as:- Paragraphs and sentence offsets, in that order.
- Submenu and submenu item offsets, in that order.
- Columnar link sets and set items, in that order.
- * Note: The comps will have # placeholders, but the data will contain actual numbers
- Layer names containing
anchor-text
indicate that a URL will be provided in another variable containinglink
in place ofanchor-text
.
The majority of variables should be output with HTML support (three curly brackets).
The exception to this is any value output within an HTML element attribute (like href
).
Once the HBS (HTML), CSS, and JS are in place to match the design comps, please package the created files.
Only the /templates/
and /assets/
directories should need to be delivered.
A zip file of the /templates/
and /assets/
directories is the expected delivery format.
All helpers from the handlebars-helpers
npm library are available in the server side rendering engine:
https://github.com/helpers/handlebars-helpers
Additionally, the following built-in helpers are available to assist with templating the GetLocal CMS data structure.
This helper is intended to assist with the -#
and -#-#
variable naming conventions.
The only argument is a required variable prefix to group and iterate over.
It works by finding all articleBody
properties that begin with the provided prefix, creating sets based on the first number encountered after the prefix, and iterative over those sets.
It can be used in a nested manner if mulitple offsets (-#-#
) are needed for paragraphs or submens.
An example of its use can be found in /templates/partials/content.hbs
.
This block helper is intended to allow for overriding or appending to a custom set of links with data driven links.
The arguments are:
- links
- The array of data driven links
- prefix
- The prefix for a set of properties in the
articleBody
that contain the custom links following theanchor-text
/link
convention.
An example of its use can be found in /templates/partials/links.hbs
.
This is a simple placeholder helper that should be inlcuded in a canonical tag in the <head>
.
This block helper assists with organizing arrays of objects for grouped list based output.
The arguments are:
- list
- The array of objects to group
- property
- The dot-notated property of each object to group by
The helper iterates over the list of objects and creates an array for each unique value found with the dot-notated property.
Each array will contain the objects that have matching property values.
It then iterates over each grouped set.
Use of the built-in {{#each}}
helper is still likely needed to iterate over the items within each group.
An example of its use can be found in /templates/partials/form.hbs