Skip to content

Commit

Permalink
some bugs fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
miroshnikov committed Sep 12, 2016
1 parent 1787b93 commit 8883805
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 109 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 Max Miroshnikov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
18 changes: 13 additions & 5 deletions smart.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,12 @@ var buildInFunctions =
}
else if (node.op == '!')
{
return (arg1 instanceof Array) ? !arg1.length : !arg1;
if (arg1 instanceof Array) {
return !arg1.length;
} else if (typeof arg1 == 'object') {
return !countProperties(arg1);
}
return arg1==='0' ? true : !arg1;
}
else
{
Expand Down Expand Up @@ -1649,7 +1654,7 @@ function getActualParamValues(params,data)

actualParams.__get = function(nm,defVal,id)
{
if (nm in actualParams && typeof(actualParams[nm]) != 'undefined')
if (nm in actualParams && typeof(actualParams[nm]) != 'undefined' && typeof(actualParams[nm]) != 'function')
{
return actualParams[nm];
}
Expand Down Expand Up @@ -1801,14 +1806,17 @@ function getTemplate(name, tree, nocache)
function stripComments(s)
{
var sRes = '';
for (var openTag=s.match(/{\*/); openTag; openTag=s.match(/{\*/))
var open = new RegExp(jSmart.prototype.left_delimiter+'\\*');
var close = new RegExp('\\*'+jSmart.prototype.right_delimiter);

for (var openTag=s.match(open); openTag; openTag=s.match(open))
{
sRes += s.slice(0,openTag.index);
s = s.slice(openTag.index+openTag[0].length);
var closeTag = s.match(/\*}/);
var closeTag = s.match(close);
if (!closeTag)
{
throw new Error('Unclosed {*');
throw new Error('Unclosed '+jSmart.left_delimiter+'*');
}
s = s.slice(closeTag.index+closeTag[0].length);
}
Expand Down
Loading

0 comments on commit 8883805

Please sign in to comment.