Permalink
Browse files

Adding test for expression into the tag

  • Loading branch information...
1 parent e6ab189 commit dff87ab0ae76f5549b2bcf81ea02a7859d722875 @krasimir committed Mar 8, 2014
@@ -1,4 +1,4 @@
-/* version: 0.3.144, born: 8-2-2014 15:35 */
+/* version: 0.3.144, born: 8-2-2014 17:24 */
var Absurd = (function(w) {
var lib = {
api: {},
@@ -1,4 +1,4 @@
-/* version: 0.3.144, born: 8-2-2014 15:35 */
+/* version: 0.3.144, born: 8-2-2014 17:24 */
var Organic = (function(w){
var o = {
helpers: {},
@@ -2060,6 +2060,35 @@ describe("Metamorphosis (to html preprocessor)", function() {
});
});
+ it("should use expressioninside the tag", function(done) {
+ var html = '\
+ <ul id="todo-list">\
+ <% for(var i=0; todo = this.todos[i]; i++) { %>\
+ <li class="<% todo.completed ? \'completed\' : \'\' %>">\
+ <div class="view">\
+ <input class="toggle" type="checkbox" <% todo.completed ? \'checked\' : \'\'%>>\
+ <label><% todo.title %></label>\
+ <button class="destroy"></button>\
+ </div>\
+ <input class="edit" value="">\
+ </li>\
+ <% } %>\
+ </ul>\
+ ';
+ api.morph("html").add(html).compile(function(err, html) {
+ expect(err).toBe(null);
+ expect(html).toBeDefined();
+ expect(html).toBe('<ul id="todo-list"><li class=""><div class="view"><input class="toggle" type="checkbox" ><label>A</label><button class="destroy"></button></div><input class="edit" value=""></li><li class="completed"><div class="view"><input class="toggle" type="checkbox" checked><label>B</label><button class="destroy"></button></div><input class="edit" value=""></li></ul>');
+ done();
+ }, {
+ minify: true,
+ todos: [
+ { title: 'A', completed: false },
+ { title: 'B', completed: true }
+ ]
+ });
+ });
+
});
describe("Metamorphosis (to html preprocessor)", function() {
@@ -148,4 +148,33 @@ describe("Metamorphosis (to html preprocessor)", function() {
});
});
+ it("should use expressioninside the tag", function(done) {
+ var html = '\
+ <ul id="todo-list">\
+ <% for(var i=0; todo = this.todos[i]; i++) { %>\
+ <li class="<% todo.completed ? \'completed\' : \'\' %>">\
+ <div class="view">\
+ <input class="toggle" type="checkbox" <% todo.completed ? \'checked\' : \'\'%>>\
+ <label><% todo.title %></label>\
+ <button class="destroy"></button>\
+ </div>\
+ <input class="edit" value="">\
+ </li>\
+ <% } %>\
+ </ul>\
+ ';
+ api.morph("html").add(html).compile(function(err, html) {
+ expect(err).toBe(null);
+ expect(html).toBeDefined();
+ expect(html).toBe('<ul id="todo-list"><li class=""><div class="view"><input class="toggle" type="checkbox" ><label>A</label><button class="destroy"></button></div><input class="edit" value=""></li><li class="completed"><div class="view"><input class="toggle" type="checkbox" checked><label>B</label><button class="destroy"></button></div><input class="edit" value=""></li></ul>');
+ done();
+ }, {
+ minify: true,
+ todos: [
+ { title: 'A', completed: false },
+ { title: 'B', completed: true }
+ ]
+ });
+ });
+
});

0 comments on commit dff87ab

Please sign in to comment.