Template files for HMRC's component library and assets-frontend
- Installing
- Developing Locally
- Adding Custom comment tags
- Adding Custom Handlebars Block Helpers
- Partials
- Contributing
- License
$ npm install --save-dev hmrc/component-library-template
To see your changes to hmrc-component-library-template
locally you'll need to link the package with npm:
$ git clone https://github.com/hmrc/component-library-template
$ cd /path/to/component-library-template
$ npm link
$ cd /path/to/assets-frontend
$ rm -rf node_modules/hmrc-component-library-template
$ npm link hmrc-component-library-template
Then every time you make an update to the template, just re-link and start the build again:
# Inside assets-frontend
$ npm link hmrc-component-library-template
If you wish to pass custom data from your .sass
comments to the
component-library-template you can do so by adding a custom tag.
To add a custom tag add the tag name to the custom
array in your kss config.json
e.g.
// config.json
"custom": [
"Example"
]
// stylesheet.scss
/*
Component title
Example: some data
Styleguide: Component
*/
// index.html
{{example}}
Block helpers make it possible to define custom functionality that is applied to what you wrap them with.
e.g.
// helpers/customHelperFile.js
Handlebars.registerHelper('bold', function(options) {
return new Handlebars.SafeString(
'<div class="mybold">'
+ options.fn(this)
+ '</div>');
});
// index.html
{{#bold}}
Some content that will be bold.
{{/bold}}
You can add custom helpers by adding a file to the helpers directory. Read the handlebars documentation or follow an example found within this folder. Theses helpers are available to use in your templates.
- Clone this repo
- Create a branch:
git checkout -b your-feature
- Make some changes
- Test your changes by running your local version
- Push your branch and open a Pull Request
This code is open source software licensed under the Apache 2.0 License.