derby-parsing
Advanced tools
Comparing version 0.7.0 to 0.7.1
@@ -330,2 +330,3 @@ var htmlUtil = require('html-util'); | ||
setContentAttribute(viewAttributes, remaining); | ||
delete viewAttributes.within; | ||
parseNode.content.push(viewInstance); | ||
@@ -561,2 +562,3 @@ } | ||
setContentAttribute(attributes, element.content); | ||
delete attributes.within; | ||
var item = createAttributesValue(attributes); | ||
@@ -563,0 +565,0 @@ var camelName = dashToCamelCase(name); |
{ | ||
"name": "derby-parsing", | ||
"version": "0.7.0", | ||
"version": "0.7.1", | ||
"description": "Add HTML template parsing to Derby", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -83,2 +83,16 @@ var expect = require('expect.js'); | ||
function stripContexts(dependencies) { | ||
if (!dependencies) return dependencies; | ||
for (var i = 0; i < dependencies.length; i++) { | ||
var dependency = dependencies[i]; | ||
for (var j = 0; j < dependency.length; j++) { | ||
var segment = dependency[j]; | ||
if (segment instanceof contexts.Context) { | ||
dependency[j] = {item: segment.item}; | ||
} | ||
} | ||
} | ||
return dependencies; | ||
} | ||
describe('template dependencies', function() { | ||
@@ -129,2 +143,39 @@ describe('text', function() { | ||
describe('each block', function() { | ||
it('gets item alias dependencies', function() { | ||
var template = createTemplate( | ||
'{{each _page.keys as #key}}' + | ||
'{{#key}}' + | ||
'{{/each}}'); | ||
expect(stripContexts(template.dependencies(context))).to.eql([ | ||
['_page', 'keys'], | ||
['_page', 'keys', {item: 0}], | ||
['_page', 'keys', {item: 1}] | ||
]); | ||
expect(template.get(context)).to.equal('redgreen'); | ||
}); | ||
it('gets index alias dependencies', function() { | ||
var template = createTemplate( | ||
'{{each _page.keys as #key, #i}}' + | ||
'{{#i}}.' + | ||
'{{/each}}'); | ||
expect(stripContexts(template.dependencies(context))).to.eql([ | ||
['_page', 'keys'], | ||
['_page', 'keys'], | ||
['_page', 'keys'], | ||
]); | ||
expect(template.get(context)).to.equal('0.1.'); | ||
}); | ||
it('gets alias dependencies from a literal', function() { | ||
var template = createTemplate( | ||
'{{each [33, 77] as #key, #i}}' + | ||
'{{#i}},{{#key}};' + | ||
'{{/each}}'); | ||
expect(stripContexts(template.dependencies(context))).to.eql(undefined); | ||
expect(template.get(context)).to.equal('0,33;1,77;'); | ||
}); | ||
}); | ||
describe('HTML', function() { | ||
@@ -131,0 +182,0 @@ it('gets dependencies', function() { |
102005
2612
12