Comparing version 0.9.2 to 0.9.3
@@ -27,3 +27,3 @@ !function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.vash=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){ | ||
"description": "Razor syntax for JS templating", | ||
"version": "0.9.2", | ||
"version": "0.9.3", | ||
"author": "Andrew Petersen <senofpeter@gmail.com>", | ||
@@ -30,0 +30,0 @@ "homepage": "https://github.com/kirbysayshi/vash", |
@@ -68,2 +68,27 @@ | ||
var curr = this.deferredTokens.pop() || this.tokens.pop(); | ||
// To find this value we must search through both deferred and | ||
// non-deferred tokens, since there could be more than just 3 | ||
// deferred tokens. | ||
// nextNonWhitespaceOrNewline | ||
var nnwon = null; | ||
for (var i = this.deferredTokens.length-1; i >= 0; i--) { | ||
if ( | ||
nnwon | ||
&& nnwon.type !== tks.WHITESPACE | ||
&& nnwon.type !== tks.NEWLINE | ||
) break; | ||
nnwon = this.deferredTokens[i]; | ||
} | ||
for (var i = this.tokens.length-1; i >= 0; i--) { | ||
if ( | ||
nnwon | ||
&& nnwon.type !== tks.WHITESPACE | ||
&& nnwon.type !== tks.NEWLINE | ||
) break; | ||
nnwon = this.tokens[i]; | ||
} | ||
var next = this.deferredTokens.pop() || this.tokens.pop(); | ||
@@ -78,2 +103,3 @@ var ahead = this.deferredTokens.pop() || this.tokens.pop(); | ||
this.lg(' ahead %s', ahead); | ||
this.lg(' nnwon %s', nnwon); | ||
@@ -84,3 +110,3 @@ if (curr._considerEscaped) { | ||
var consumed = this[dispatch](this.node, curr, next, ahead); | ||
var consumed = this[dispatch](this.node, curr, next, ahead, nnwon); | ||
@@ -802,3 +828,3 @@ if (ahead) { | ||
Parser.prototype.continueBlockNode = function(node, curr, next, ahead) { | ||
Parser.prototype.continueBlockNode = function(node, curr, next, ahead, nnwon) { | ||
@@ -898,8 +924,7 @@ var valueNode = node.values[node.values.length-1]; | ||
// Try to leave whitespace where it belongs. | ||
// Try to leave whitespace where it belongs, and allow `else {` to | ||
// be continued as the tail of this block. | ||
if ( | ||
next | ||
&& (next.type === tks.WHITESPACE || next.type === tks.NEWLINE) | ||
&& ahead | ||
&& ahead.type !== tks.BLOCK_KEYWORD | ||
nnwon | ||
&& nnwon.type !== tks.BLOCK_KEYWORD | ||
) { | ||
@@ -906,0 +931,0 @@ this.closeNode(node); |
@@ -74,3 +74,3 @@ // The order of these is important, as it is the order in which | ||
} | ||
, 'WHITESPACE', (/^(\s)/) | ||
, 'WHITESPACE', (/^(\s+)/) | ||
, 'FUNCTION', (/^(function)(?![\d\w])/) | ||
@@ -77,0 +77,0 @@ , 'BLOCK_KEYWORD', (/^(catch|do|else|finally|for|function|goto|if|switch|try|while|with)(?![\d\w])/) |
{ | ||
"name": "vash", | ||
"description": "Razor syntax for JS templating", | ||
"version": "0.9.2", | ||
"version": "0.9.3", | ||
"author": "Andrew Petersen <senofpeter@gmail.com>", | ||
@@ -6,0 +6,0 @@ "homepage": "https://github.com/kirbysayshi/vash", |
@@ -654,2 +654,9 @@ var vows = require('vows') | ||
} | ||
,'markup within a code block with if/else on new lines': { | ||
topic: '@if(true)\n{\n<strong>Hello</strong>\n}\n else\n{\n <strong>World!</strong>\n }' | ||
,'outputs': function(topic) { | ||
var tpl = vash.compile(topic); | ||
assert.equal(tpl(), '<strong>Hello</strong>'); | ||
} | ||
} | ||
,'markup within a code block followed by else with markup': { | ||
@@ -656,0 +663,0 @@ topic: function(){ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
469934
11361