TemplateHelpers

Condensation specific helpers for common tasks

Kind: global namespace


arrayify(...str)

Turn a string into a JSON parseable array. Each value is processed with cValue

Kind: static method of TemplateHelpers
Returns: String - - When parsed will be an array

Param Type Description
...str string String to use if block is not present

Example

{{arrayify "string" (ref "Parameter1") }}

Example

{{arrayify (ref "Parameter1")}}

assetPath(path)

Build the S3 path to an asset particle within the project

Kind: static method of TemplateHelpers
Returns: String - - S3 path to the asset

Param Type Description
path string the path to the particle relative to the assets directory

Example

{{assetPath "myasset.zip"}}

Example

{{assetPath "path/to/myasset.sh"}}

cValue(str, options)

Coerce Value

Will check to see if a string is a parsable object. If it is, then it will be left alone and simply returned back.

If the string is not a parseable object it will be made JSON compliant and returned.

If the string is empty, null, undefined or otherwise falsey then an empty string will be returned.

Kind: static method of TemplateHelpers
Summary: Coerce value

Param Type Description
str string The string to evaluate
options Object options object from Handlebars
options.forceNumber boolean return a number at all costs

Example

---
foo: bar
baz: {"Ref": "LogicalId"}
faz: "5"
---
{{cValue foo}}
{{cValue baz}}
{{cValue faz forceNumber=true}}

layout([options])

Start a layout

Kind: static method of TemplateHelpers
Returns: string - - CloudFormation Template

Param Type Default Description
[options] Object options object from Handlebars
[options.AWSTemplateFormatVersion] string "2010-09-09" AWS Format Version
[options.TemplateDescription] string Description for the template
[options.Transform] string AWS Transform type for the template

Example

---
things:
-
  name: subnet1
  cidr: "10.0.0.0/24"
-
  name subnet2
  cidr: "10.0.1.0/24"
---

{{#layout templateDescription="condensation rocks!"}}
  {{parameter 'my_parameter' logicalId="MyParameter"}}
  {{condition 'my_condition' logicalId="MyCondition"}}

  {{! helpers can occur in any order, allowing you to group related section parts together }}

  {{#each things}}
    {{parameter 'repeate_me' logicalId="RepeateMe" logicalIdSuffix=@index}}
    {{condition 'repeate_me' logicalId="RepeateMeCond" logicalIdSuffix=@index}}
    {{resource 'repeate_me' logicalId="RepeateMeResource" logicalIdSuffix=@index}}
    {{output 'repeate_me' logicalId="RepeateMeOutput" logicalIdSuffix=@index}}
  {{/each}}
{{/layout}} 

objectify([...options])

Return options as a stringified object

Kind: static method of TemplateHelpers
Returns: String - - When parsed will be an object

Param Type Description
[...options] kv Key/Value pairs to pass to the particle helper

Example

{{objectify Param1="Value1" Param2=(ref "AWS::Region")}}

requireAssets(globPath)

Include a glob of assets

Only needed for assets that are not directly referenced by another particle

Kind: static method of TemplateHelpers

Param Type Description
globPath string Glob patter of assets to package with the project

Example

{{requireAssets "all_of_these/**"}}

Example

{{requireAssets "module:<MODULE>" 'all_from_module/**'}}

Example

{{!-- to load modules with format `particles-NAME` --}}
{{requireAssets "m:<NAME>" "all_from_module/**"}}

scopeId()

Used within sets to add the correct logicalIdPrefix and/or logicalIdSuffix to a logicalId

Kind: static method of TemplateHelpers
Returns: string - - The logical with the correct prefix and suffix for the current scope

Type Description
string The logicalId

Example

{{scopeId "LogicalId"}}

Example

{{ref (scopeId "LogicalId")}}

templateUrl(path)

Generate an S3 URL for another template in the project

Kind: static method of TemplateHelpers

Param Type Description
path string Path to the template (file extensions optional)

Example

{{templateUrl "another.template.json"}}

Example

{{templateUrl "module:<MODULE>" 'another.template.json'}}

Example

{{!-- to load modules with format `particles-NAME` --}}
{{set "m:<NAME>" "another.template.json"}}