Skip to content

Commit

Permalink
Merge branch 'release/0.5.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
kmcgrath committed Apr 29, 2016
2 parents 6e69ae1 + b77da32 commit 359e102
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -18,7 +18,7 @@ env:
- secure: kUaJjK1l+A/x1LnTscwzOYdBaFekJ+wv6AQtYXmOiz3SPPDTbizD+pLUs+ZRBvWi2D5e6LivvBKLoOn5mvr/KSip0hriTCBwfjK+Sx8+kreXUv+gZXX+gCd37CCpp5PuOba0nErwNn3TAV3tCnMkUp0wxFnOdREXeCFv/qYEzGo=
deploy:
provider: npm
email: as.us.labs@sungardas.com
email: as.us.awscto@sungardas.com
api_key:
secure: IafCsbxGASncqJ1b90lR91bbGqyUoO5ljuJRab+qvQenJafts7LAFeaYxpT0o8eRFZYwsJwAjJeqV1S8NcT4/Dz6NAbi2b3+f1qY0viXk2rWyZhHWgPjMKOQFTw2tEhbkAW2hMYf6YvAW087hnrXUVXQqlcw/p39EzN8WYxAIe8=
on:
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -2,7 +2,7 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
## [0.5.1] - 2016-04-29
### Added
- `ref` helper
- `scopeId` helper
Expand Down
44 changes: 44 additions & 0 deletions README.md
Expand Up @@ -411,6 +411,31 @@ Helper: `set`
The particle path can match the base name of the file or the base name
plus any extensions.

##### Scoping

Sets can be repeated multiple times in a template. Sets can also be
embedded within other sets. To help with namespacing a set can be
scoped with a `logicalIdPrefix` and/or a 'logicalIdSuffix`. These
values will be apporperiately added to and logicalIds within the set.

To reference a logicalId within a scoped set use the `scopeId` and `ref`
handlebars helpers provided by condensation.

{{!-- sets/my_set.hbs --}}
{{parameter "cidr" logicalId="Cidr"}}
{{resource "subnet" logicalId="Subnet" cidr=(ref "cidr")}}

---

{{!-- cftemplates/my_template.template.json.hbs --}}

{{set "my_set" logicalIdSuffix="1"}}
{{set "my_set" logicalIdSuffix="2"}}

The definition above would produce two parameters, `Cidr1` and `Cidr2`, and
two resources, `Subnet1` and `Subnet2`. Each subnet will reference
their respective Cidr parameter.

### Tasks

Get a full list of tasks by running `gulp -T`
Expand Down Expand Up @@ -490,6 +515,25 @@ Deploy templates to all S3 buckets that contain the label, LABEL.
dist: 'dist'
};

## Condensation Helpers

### ref

Build a reference to a logicalId. By default `ref` will return a
logicalId in relation to it's scope adding any logicalIdPrefix and/or
logicalIdSuffix as necessary. This can be turned off by setting `scope`
to `false`.

{{ref 'MyParameter'}}
{{ref 'MyParameter' scope=false}}

### scopeId

Return a logicalId based on it's current scope. Will add any
logicalIdPrefix and/or logicalIdSuffix that is defined.

{{scopeId 'MyParameter'}}

## Handlebars Helpers

Aside from the helpers to load particles, condensation provides the
Expand Down
10 changes: 9 additions & 1 deletion lib/condensation/template-helpers/ref.js
@@ -1,7 +1,15 @@
var scopeId = require("./scopeId");

/*
* Will create a reference to a logicalId within the template based on it's scope.
* If scope is enabled the logicalIdPrefix and logicalIdSuffix will be added automatically.
*
* @param {string} - The logicalId to reference
* @param {Object} options - options for creting the logicalId reference
* @param {Boolean} [options.scope=true] - Whether to scope the logicalId or not
*/
module.exports = function(str,options) {
options = options || {};
options = options || {};
if (options.scope !== false) {
str = scopeId.apply(this,[str]);
}
Expand Down
8 changes: 7 additions & 1 deletion lib/condensation/template-helpers/scopeId.js
@@ -1,4 +1,10 @@

/*
* Will create a return a logicalId scoped with logicalIdPrefix and logicalIdSuffix
*
* @param {string} - The logicalId
* @param {Object} options - unused at this time
* @return {string}
*/
module.exports = function scopeId(str,options) {
var scopeStr = [this.logicalIdPrefix,str,this.logicalIdSuffix].join('');
return scopeStr;
Expand Down
4 changes: 2 additions & 2 deletions package.json
@@ -1,8 +1,8 @@
{
"name": "condensation",
"version": "0.5.1-rc1",
"version": "0.5.1",
"publishConfig": {
"tag": "rc"
"tag": "latest"
},
"description": "Package, reuse and share particles for CloudFormation projects",
"main": "index.js",
Expand Down

0 comments on commit 359e102

Please sign in to comment.