Skip to content

Commit

Permalink
v3.1.0 allow templated keys
Browse files Browse the repository at this point in the history
  • Loading branch information
erikwilson / iamruinous authored and erikwilson / iamruinous committed Feb 1, 2017
1 parent 100a39a commit b8f8298
Show file tree
Hide file tree
Showing 4 changed files with 570 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "christacheio",
"version": "3.0.5",
"version": "3.1.0",
"description": "Christacheio, a mustache with {{pizzaz}}",
"main": "index.js",
"directories": {
Expand Down
2 changes: 2 additions & 0 deletions src/christacheio.coffee
Expand Up @@ -47,6 +47,8 @@ stacheception = (stache, obj, options, limbo=[]) ->
limbo.push stache
_.forOwn stache, (value, key) ->
return if _.includes limbo, value
delete stache[key]
key = stachest key, obj, options
if _.isObject value
stache[key] = stacheception value, obj, options, limbo
return
Expand Down
22 changes: 22 additions & 0 deletions test/christacheio-spec.coffee
Expand Up @@ -47,6 +47,28 @@ describe 'christacheio', ->
it 'should replace the mustached area', ->
expect(@result).to.deep.equal 'pistachio'

describe 'when keys are templates', ->
beforeEach ->
sampleObject =
'{{nut}}': 'nut'
'nut': "{{nut}}"

@result = christacheio sampleObject, nut: 'pistachio'

it 'should replace the mustached key', ->
expect(@result).to.deep.equal pistachio: 'nut', nut: 'pistachio'

describe 'when keys are templates', ->
beforeEach ->
sampleObject =
'nut.{{nut}}': 'nut'
'nut': "nut.{{nut}}"

@result = christacheio sampleObject, nut: 'pistachio'

it 'should replace the mustached key', ->
expect(@result).to.deep.equal 'nut.pistachio': 'nut', nut: 'nut.pistachio'

describe 'when called with two passes, like the engine', ->
beforeEach ->
sampleObject =
Expand Down

0 comments on commit b8f8298

Please sign in to comment.