Features
Provides structural formatting for Blaze/Spacebars blocks:
{{#if}} ... {{/if}}
{{#unless}} ... {{/unless}}
{{#each}} ... {{/each}}
{{#with}} ... {{/with}}
{{else}}
Before:
{{#each users}} {{#if active}}
<span>{{name}}</span>
{{else}}
<span>Inactive</span>
{{/if}} {{/each}}
After:
{{#each users}}
{{#if active}}
<span>{{name}}</span>
{{else}}
<span>Inactive</span>
{{/if}}
{{/each}}
Blaze Forge understands nested Spacebars blocks and keeps their structure properly indented.
Inline Spacebars expressions inside HTML attributes are intentionally left untouched.
Multiline Template Includes
Long template inclusions are formatted into a more readable structure.
Before:
{{> generateQR receptionId=(receptionIdToObjectId _id) userReceptionCode=userReceptionCode statePayment=statePayment moduleType="RECEPTION"}}
After:
{{> generateQR
receptionId=(receptionIdToObjectId _id)
userReceptionCode=userReceptionCode
statePayment=statePayment
moduleType="RECEPTION"
}}
Helper Autocomplete
Blaze Forge indexes helpers registered for a specific template.
Template.userProfile.helpers({
fullName() {
return "John Doe";
},
isActive() {
return true;
},
});
Inside the corresponding template:
<template name="userProfile">
<p>{{fullName}}</p>
{{#if isActive}}
<span>Active</span>
{{/if}}
</template>
Blaze Forge provides autocomplete suggestions for fullName and isActive.
Global Helpers
Global Blaze helpers registered with Template.registerHelper are also indexed:
Template.registerHelper("checklogin", function () {
if (Meteor.userId()) {
Router.go("/home");
} else {
Router.go("/");
}
});
The helper can then be used from any Blaze template:
{{checklogin}}
Global helpers are available through autocomplete across your Blaze templates.
Go to Helper Definition
Use Ctrl + Click or Go to Definition on a helper:
{{checkPayment _id}}
Blaze Forge navigates directly to its definition:
Template.reception.helpers({
checkPayment(id) {
// ...
},
});
This also works with global helpers:
{{checklogin}}
which can navigate to:
Template.registerHelper("checklogin", function () {
// ...
});
Blaze Block Validation
Blaze Forge detects missing or incorrectly structured Blaze blocks while you edit.
For example:
{{#if user}}
<div>
{{name}}
</div>
Blaze Forge detects that the block is missing:
{{/if}}
It currently validates:
{{#if}}
{{#unless}}
{{#each}}
{{#with}}
{{else}}
It can detect:
- Missing block closures
- Incorrect block closures
- Orphan closing blocks
{{else}} without an open block
- Problems with nested Blaze blocks
Blaze expressions inside HTML comments are ignored:
<!--
{{#if disabled}}
This block is ignored.
{{/if}}
-->