Giter Site home page Giter Site logo

miroshnikov / jsmart Goto Github PK

View Code? Open in Web Editor NEW
104.0 104.0 27.0 1.52 MB

JavaScript template engine, port of the PHP template engine Smarty to Javascript, lets you use the same templates for PHP and JavaScript, on both server and client-side.

License: MIT License

HTML 1.34% JavaScript 37.00% ApacheConf 0.12% PHP 5.38% CSS 4.14% Smarty 52.02%

jsmart's People

Contributors

miroshnikov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jsmart's Issues

nesting if statement with else token will throw an Exception

What steps will reproduce the problem?

{if $foo}foo {if $bar}bar{else}nobar{/if}{/if}


What is the expected output? What do you see instead?

Unclosed {if +[^}]*}
throw new Error('Unclosed {'+reOpen+'}'); 


What version of the product are you using? On what operating system?

all

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 18 Aug 2011 at 1:07

Error on check for identity

What steps will reproduce the problem?

Execute:

 new jSmart('{1 === true}').fetch()

What is the expected output? What do you see instead?

Should return false, but instead a get error "TypeError: Cannot read property 
'0' of undefined"

What version of the product are you using? On what operating system?

jsmart 2.9
Windows 8 64bit, Google Chrome 27.0.1453.94 m

Original issue reported on code.google.com by [email protected] on 4 Jun 2013 at 8:24

nl2br fails with numbers

Using nl2br on string with only numbers I got the following error: 
Uncaught Error: Object 123123123123 has no method 'replace' in nl2br(nl2br__p0) 

I use smart-2.10.min.js

You can try it on http://www.qualcosadafare.it/test/prova.php


--- prova.php ---

<html>
<head>
<script type="text/javascript" src="smart-2.10.min.js"></script>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
  var tpl;

  $.get('commento.tpl','',function(reply) { tpl=reply; });

  $(document).ready(function() {
    $('#btQDF').click(function() {
      var testo, res;
      res=tpl.fetch({
        dettaglio: [{commento:'123123123'}]
      });
      testo='<br/><div id="dettview">'+res+'</div>';
      $('#pQDF').html(testo);
    });
  });
</script>
</head>

<body>
<p id="btQDF">Test</p>
<p id="pQDF"></p>
</body>
</html>


--- commento.tpl ---

{foreach $dettaglio as $i => $commento}
 <p>{$commento.commento|nl2br}</p>
{/foreach}

Original issue reported on code.google.com by [email protected] on 27 Jan 2014 at 11:43

Caching problem

http://code.google.com/p/jsmart/wiki/caching
the caching method is great, but only in browser.

I want to use jSmart in my asp project, using the code :

>>>

    var name = xxxx;
    var f = new F.File('/bin/data/template_c/' + name);
    var text = null;
    var tpl;
    if (f.exist()) {
        text = f.getText();
        tpl = new jSmart();
        tpl.tree = eval(text);
    }else{
        tpl = new jSmart(f.getText());
        text = F.json.stringify(tpl.tree);
        f.setText(text);
    }

however, some var in tpl.tree are Array type, but they have Non-number 
properties. So they can not be json stringified.

Can you fix it? 

Original issue reported on code.google.com by [email protected] on 4 Jun 2012 at 9:54

custom function

Its not possible to implement custom function like strtolower or isset() without rewriting the template completely

How to use a Smarty template ? path to template?

i failed to use the Smarty template, 

source code:
a.tpl:

{literal}
<div id='result'></div>
<script type="text/x-jsmart-tmpl" id='myTemplate'>
   {fetch file='b.tpl'}
</script>
<script language="javascript">
<!--
$.getJSON("*********",
  function(json) {
      var tpl = new jSmart( document.getElementById('myTemplate').innerHTML );
      var res = tpl.fetch(json);
      document.getElementById('result').innerHTML = res;
  });
-->
</script>
{/literal}



error message:

error: No file for /b.tpl
source file: http://*********/smart-2.9.min.js
line: 50


i put the b.tpl together with a.tpl,
however,neither absolute path nor relative path works. Do you have any 
suggestion?

Original issue reported on code.google.com by [email protected] on 11 Jul 2012 at 2:01

function with arguments dont work

If there is native function called with argument it doesn't work.

Example:-

{if checkSomething("hello") && false}
Hello Miroshnikov
{/if}

This always print Hello Miroshnikov, doesn't matter what checkSomething returns and even if there is false in the 2nd part of condition.

Above does work well, PHP Smarty

Nested else statement cannot be parsed

What steps will reproduce the problem?
  var tpl = new jSmart('{if $condition}{if $condition}OK{else}NOT OK{/if}OK{/if}');
  var data = { 'condition': 1 };
  var res = tpl.fetch(data);

What is the expected output? What do you see instead?
  "OKOK" output expected, Exception thrown: "Uncaught Error: Unclosed {if +[^}]*}".

What version of the product are you using? On what operating system?
  2.0 from June 27th

Please provide any additional information below.
  Removing the else from the template makes everything work properly.

Original issue reported on code.google.com by [email protected] on 7 Aug 2011 at 2:14

Invitation to Hanjst

Hi all of fans of Smarty,

This is not a issue but an option.
Hanjst has just been created to be a descendant for Smarty in back-end and front-end.
Please help have a try if you kick-start a wholly-new project.

Hanjst uses the same syntax and semantics with Smarty as we are all fans of Smarty.

Regards,

Wadelau

Multi Extends within same page

What steps will reproduce the problem?
1. Create 2 jSmart object with differing templates (See attached)
2. The second template is always used.

The attached use console.log

It should Produce:
<div>
Test:<br/>
I won't change this.
The extended content that should show.
</div>

<div>
Test:<br/>
I won't change this.
This is Berts Content.
</div>

It Produces:
<div>
Test:<br/>
I won't change this.
This is Berts Content.
</div>

<div>
Test:<br/>
I won't change this.
This is Berts Content.
</div>


Latest Version.

Original issue reported on code.google.com by [email protected] on 7 Jun 2011 at 2:34

Attachments:

empty function

Hi, I want to know if it were possible that you add compatibility for the "empty" depending on the conditions
Example:
{if !empty($var)} // {if empty($var)}

Broken output in variables in iOS7 Safari

In safari iOS7. If you have an item in an array with curly brackets:

var myArray = ["{$name}"];

and then you try to convert this array into an object:

myArray.my_variable = "variable value";

you will get:

myArray {
  0:"$name",
  my_variable:"variable value"
}

This is exactly what's happening on line 123 in the findTag() function.
To fix, inverse the two lines:

found.index = offset;
found[0] = s.slice(0,i+rdelim.length);

Original issue reported on code.google.com by [email protected] on 23 Sep 2013 at 5:55

Conditional statements with custom function call in them behaved wrong.

What steps will reproduce the problem?

What steps will reproduce the problem?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>jSmart example</title>
    <script type="text/javascript" src="smart-2.9.min.js"></script>
</head>
<body>

<script id="test_tpl" type="text/x-jsmart-tmpl">
    {if isset($var) && false}
        False condition block.
    {else}
        True condition block.
    {/if}
</script>

<script type="text/javascript">
        function isset(val) { return (typeof val !== 'undefined'); }
    var tpl = new jSmart(document.getElementById('test_tpl').innerHTML);
    var res = tpl.fetch({'var': 'foo'});
    document.write( res );
</script>


</body>
</html>

What is the expected output? What do you see instead?
Expected: True condition block.
Actual: False condition block.


Please provide any additional information below.

Here in if statement, first condition is true but second condition is false, 
but it ignores the second and goes inside the if block. 

Original issue reported on code.google.com by [email protected] on 12 Nov 2013 at 1:20

Caching of "extends" and caching causing problem when rendering multiple times

What steps will reproduce the problem?
1. Create template base_tpl :

<div>{block name='content'}{/block}</div>

2. Create template 'child_tpl': 

{extends file='base_tpl'}{block name='content'}My Content{/block}

3. Render "child_tpl" twice

What is the expected output? What do you see instead?

Should render correctly both times but instead second time output is empty.

What version of the product are you using? On what operating system?

2.9

Please provide any additional information below.

It seems caching in getTemplate(nane,tree,nocache) is causing a problem when 
used for extends. 
Disabling caching of extends (line 778) works around the issue:

 -                     getTemplate(trimQuotes(params.file?params.file:params[0]),tree);
 +                     getTemplate(trimQuotes(params.file?params.file:params[0]),tree, true);

Obviously, a fix where extends is cached would be preferable.

-b

Original issue reported on code.google.com by [email protected] on 6 Apr 2013 at 8:16

Casting bug on empty array

What steps will reproduce the problem?
1. {$test = []}
2. {if $test == false} empty {else} not empty{/if}
3. {if !$test} empty {else} not empty{/if}

What is the expected output? What do you see instead?
Expect 2 & 3 to output "empty", this happens on server side smarty.
However, something weird happens with the casting on: !$test

What version of the product are you using? On what operating system?
2.11 in Firefox 36.0.1 on Windows 7 x64

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 10 Mar 2015 at 10:10

html_options multiple selections

I think there is a problem with html_options and multiple selected values. I have tried all code variations I could think of but none works. It only selects one value if it selects one at all.

{html_options values=['1','2','3','4'] output=['one','two','three','four'] selected=['1'']}

Output:

 <option value="1" selected="selected">one</option>
 <option value="2">two</option>
 <option value="3">three</option>
 <option value="4">four</option>


{html_options values=['1','2','3','4'] output=['one','two','three','four'] selected=['1','3']}

Output:

 <option value="1">one</option>
 <option value="2">two</option>
 <option value="3">three</option>
 <option value="4">four</option>

Expected output:

 <option value="1" selected="selected">one</option>
 <option value="2">two</option>
 <option value="3" selected="selected">three</option>
 <option value="4">four</option>

capitalize with accent

What steps will reproduce the problem?
1. Try to output : "août"|capitalize

What is the expected output? What do you see instead?
Expected : Août
Instead of : AoÛT

What version of the product are you using? On what operating system?
Jsmart 2.9 min
Firefox 20.0
Mac OS X 10.8.3

Please provide any additional information below.

A Quick fix is to use another plugin:
jSmart.prototype.registerPlugin("modifier", "capitalize2", function(a, b) {
 var tab = a.split(" ");
 for(var i = 0 ; i < tab.length; i++){
  tab[i]=tab[i].substr(0,1).toUpperCase() + tab[i].slice(1);
 }
 return tab.join(" ");
});

Original issue reported on code.google.com by [email protected] on 22 May 2013 at 1:11

foreach with objects

Hi,
I had a problem with a simple foreach:

{foreach $FileList as $Key => $File}

{/foreach}

$FileList is an object like this:

[12/c108cc0cde03c332305ecb74be64a476.png: Object]
12/c108cc0cde03c332305ecb74be64a476.png: Object
FileID: "12/c108cc0cde03c332305ecb74be64a476.png"

But the foreach doesn't work. I found that the problem is the if statement @ row 680:

if (!(a instanceof Object))

changed to:

if (!(typeof a == 'object'))

and it works fine. I think that the origin of the problem is that I use jsmart inside a iframe and FileList comes from the parent window, and it fails to compare the object of the parent window with the "Object" of the iframe.

I'm opening this issue because I'm not satisfied with a solution that requires to manually patch external libraries. :)

Thank you!

Patch for /smart.js: modifier plugin names conflict with template variable names

If there is both a modifier and a variable in a scope, the two will conflict, 
and the modifier won't be accessible within the data section.

Example:
jSmart.prototype.registerPlugin(
    'modifier', 
    'round', 
    function(num, digits)
    {
        var multiplier = Math.pow(10, digits);
        return Math.round(num * multiplier) / multiplier;
    }
);

var tpl = new jSmart('{$round} {$num|round:2}');
tpl.fetch({a: 2.1324, round: 2});

Original issue reported on code.google.com by [email protected] on 30 Dec 2012 at 10:10

Attachments:

IE9 critical error in process()

What steps will reproduce the problem?
1. Launch demo http://sites.google.com/site/jsmartdemo/

Script execution is halt on error, nothing is displayed:

SCRIPT5007: Unable to get value of the property 'type': object is null or 
undefined 

smart.js, line 1630 character 13

(error msg produced by IE developer tools)


Original issue reported on code.google.com by jani.mensonen on 9 Nov 2011 at 6:03

fixed some problems run in asp

What steps will reproduce the problem?
1.use it in asp
2.asp in javascript
3.parse Error



change "function findTag(re,s)" body:


if (s[i] == '{')      ==>      if (s.substr(i, 1) == '{')
if (s[i] == '}')      ==>      if (s.substr(i,1) == '}')

Original issue reported on code.google.com by [email protected] on 5 May 2011 at 11:22

Foreach doesn't support Smarty Format?

What steps will reproduce the problem?
Change the example to use the from + item variables in foreach as described 
http://www.smarty.net/docsv2/en/language.function.foreach


Will you add support for the classic foreach format?

Original issue reported on code.google.com by [email protected] on 13 May 2011 at 12:54

Patch for /smart.js: make {if} return false for empty regular and associative arrays

Great job guys! jSmart's definitely saved me and my team a few days of work in 
porting templates over.

We discovered this issue where empty arrays would still equal to true in 
Javascript. The changes above should fix that.

BEFORE:
var tpl = new jSmart('{if $a}hello{/if}');
tpl.fetch({a: []}); // "hello"
tpl.fetch({a: [1]}); // "hello"
tpl.fetch({a: {}}); // "hello"
tpl.fetch({a: {b: 'c'}}); // "hello"

NOW:
var tpl = new jSmart('{if $a}hello{/if}');
tpl.fetch({a: []}); // ""
tpl.fetch({a: [1]}); // "hello"
tpl.fetch({a: {}}); // ""
tpl.fetch({a: {b: 'c'}}); // "hello"

Original issue reported on code.google.com by [email protected] on 31 Dec 2012 at 7:50

Attachments:

Assign with inner variables.

What steps will reproduce the problem?
I have attached an example HTML file.

The output from the attached should exactly match the example.

Unsure if this is intended functionality (in Smarty3) but jSmart doesn't 
reproduce this.





Original issue reported on code.google.com by [email protected] on 21 Apr 2011 at 3:12

Attachments:

Assign JSON/Object/Function in template

What steps will reproduce the problem?

Attached HTML best shows the issue.

Assign a JSON object to the template. Use {Assign} to allocate this to a new 
variable name and then call a property/attribute/thing.

Using console.log again.

What is the expected output? 

<div>
Test:<br/>
macintosh
macintosh
</div>


What do you see instead?

<div>
Test:<br/>
macintosh
undefined
</div>



Original issue reported on code.google.com by [email protected] on 9 Jun 2011 at 3:03

Attachments:

Operator precedence - "|" more important than "*".

What steps will reproduce the problem?
<td>{$item.discount*100|float:1}%</td>

What is the expected output?

<td>10,0%</td>

What do you see instead?

NaN%

What version of the product are you using? On what operating system?

2.7

Please provide any additional information below.

To overcome the problem:

{assign var='discount' value=$item.discount*100}
<td>{$discount|float:1}%</td>

Original issue reported on code.google.com by [email protected] on 9 Feb 2012 at 9:06

Unknown functions do not throw an exception any more

What steps will reproduce the problem?
var tpl = new jSmart('{$tt|toInt}');
var data = { "tt" : "TYYY" };
var res = tpl.fetch(data);

What is the expected output? What do you see instead?
Expected: Exception thrown, no output
Actual: TYYY

What version of the product are you using? On what operating system?
2.2

Please provide any additional information below.
var tpl = new jSmart('{$tt|parseInt}');
var data = { "tt" : "TYYY" };
var res = tpl.fetch(data);

Works as expected. Shows "NaN"

Original issue reported on code.google.com by [email protected] on 2 Sep 2011 at 8:25

iOS7 - wrong output when using blocks

What steps will reproduce the problem?
1. Just run the fiddle: http://jsfiddle.net/9CshS/

What is the expected output? 
"test"

What do you see instead?
"t}testt}"


What version of the product are you using? On what operating system?
2.9

Original issue reported on code.google.com by [email protected] on 8 Oct 2013 at 3:43

operator "===" parsed as "==" with param "="

What steps will reproduce the problem?
1. var tpl = new jSmart("{if $booleanFalse === false}OK{else}WRONG{/if}");
2. tpl.fetch({'booleanFlase':false});
3.

What is the expected output? What do you see instead?
Expect: "OK", 
See: TypeError: Cannot read property '0' of undefined
get stack: function () { [native code] }
message: "Cannot read property '0' of undefined"
set stack: function () { [native code] }
__proto__: Error

What version of the product are you using? On what operating system?
smart-2.9 on Ubuntu 12.04, with Google Chrome Version 28.0.1500.52

Please provide any additional information below.

Problem happens on parsing tokens[8]:             
1222: {
1223:   re: /^\s*(==|!=|===|!==)\s*/,
1224:   parse: function(e, s)
1225:   {
1226:     parseOperator(RegExp.$1, 'binary', 6, e.tree);
1227:   }
1228: }

First match is "==". If swap operators in regular expression like this
re: /^\s*(===|!==|==|!=)\s*/ then work fine.

Original issue reported on code.google.com by [email protected] on 26 Jun 2013 at 2:59

Attachments:

Parser fails to understand nested curly braces inside an elseif.

What steps will reproduce the problem?

Run the following template in a browser with smart-2.9.min.js in the same 
directory:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Demo of jsmart elseif bug</title>
    <script type="text/javascript" src="smart-2.9.min.js"></script>
</head>
<body>
    <script id="test_tpl" type="text/x-jsmart-tmpl">
        {if true}
            <p>A</p>
        {elseif $data.foo}
            <p>B</p>
        {else}
            <p>C</p>
        {/if}
    </script>
    <script type="text/javascript">
        var data = {
            foo: false
        };

        var tpl = new jSmart(document.getElementById('test_tpl').innerHTML);
        var res = tpl.fetch(data);
        document.write(res);
    </script>
</body>
</html>

What is the expected output? What do you see instead?

Expected:

A

Actual:

A

elseif

B

What version of the product are you using? On what operating system?

2.9, Chrome/OS X (but not specific to that combination I don't believe).

Please provide any additional information below.

See also issue #23 for a sort-of related elseif issue.

Original issue reported on code.google.com by [email protected] on 3 Jun 2013 at 3:31

Demo page doesn't work out of the box

https://jsfiddle.net/miroshnikov/6tfz9p3z/1/

This line (27) doesn't work:
var res = document.getElementById('test_tpl').innerHTML.fetch(data);

In console:

VM78:75 Uncaught TypeError: document.getElementById(...).innerHTML.fetch is not a function
    at window.onload (VM78:75)

When commented out, the demo works. Browser: Chrome Version 60.0.3112.101 (Official Build) (64-bit)

Array Assign in template

What steps will reproduce the problem?
1. Attached HTML

What is the expected output? 
<div>
Test:<br/>
a
b
c
</div>

What do you see instead?
<div>
Test:<br/>
$test
</div>

FYI: this is higher priority for me than issue 8.

Original issue reported on code.google.com by [email protected] on 24 Jun 2011 at 3:03

Attachments:

Browser support

Hey Guys, can you add the Version which you support for the most used Browsers to the README.md.

Parse error on { with no white space next to {literal}

What steps will reproduce the problem?
var tpl = new jSmart('{{literal}{if $condition}OK{else}NOT OK{/if}{/literal}}');
var data = { 'condition': 1 };
var res = tpl.fetch(data);

What is the expected output? What do you see instead?
{{if $condition}OK{else}NOT OK{/if}}

What version of the product are you using? On what operating system?
2.2

Please provide any additional information below.
{ {literal}{if $condition}OK{else}NOT OK{/if}{/literal} }
works OK (with extra white space)!

Original issue reported on code.google.com by [email protected] on 2 Sep 2011 at 7:52

multy comparison

var s = 111;
function isset(v){
return typeof v != 'undefined'
}
console.log( isset(s) ) // TRUE
var compiled = new jSmart( '{if isset($a) && $a==$b}1{else}2{/if}' ); // 1 // a != b
console.log( compiled.fetch( {a:'Hello', b:'John'} ) );

"$var is not defined" error when variable is not set

What steps will reproduce the problem?
1. If you look at your Javascript data object example on homepage, you have 
'price' : ''. But what if 'price' variable was not set at all? Remove it 
completely.
2. Try to fetch a template
3. Firebug returns error in console ('$var is not defined').

What is the expected output? What do you see instead?
So it's ok to say {if $var} in Smarty as long as the variable is set, but is 
empty. Instead, I also want included the ability to detect unset variables, for 
example if we had:

 { 'title'  : 'Murach JavaScript and DOM Scripting',
   'author' : 'Ray Harris'
 }

i should still be able to say {if $book.price}{$book.price}{else}Display this 
text or nothing{/if}

Currently, I'm having to set variables as empty strings in other areas of my 
code where I shouldn't have to!

What version of the product are you using?
I downloaded the latest from svn

Please provide any additional information below.
I minified smart.js from svn with yui tools but i don't think it should have 
any effect on unset variable errors.

Original issue reported on code.google.com by [email protected] on 15 May 2011 at 7:46

Foreach does not work on multi-dimensional arrays

What steps will reproduce the problem?
var tpl = new jSmart('{foreach from=$Question.Answers key="aid" item="answer" 
name="Loop"}{$aid}: {$answer}<br/>{/foreach}');
var data = {
'Question': { "Answers" : { 1: 'one', 2: 'two' } }
};
var res = tpl.fetch(data);

What is the expected output? What do you see instead?
Expected:
1: one
2: two

Actual:
0: $Question.Answers

What version of the product are you using? On what operating system?
2.2

Please provide any additional information below.
One dimensional array in foreach works as expected:

var tpl = new jSmart('{foreach from=$Answers key="aid" item="answer" 
name="Loop"}{$aid}: {$answer}<br/>{/foreach}');
var data = {
"Answers" : { 1: 'one', 2: 'two' }
};
var res = tpl.fetch(data);

Original issue reported on code.google.com by [email protected] on 2 Sep 2011 at 8:45

Include from Variable

What steps will reproduce the problem?
1. Attached HTML Document

What is the expected output? 
Same As http://code.google.com/p/jsmart/wiki/IncludeTemplates

What do you see instead?
Uncaught TypeError: Cannot read property 'value' of null

Smarty Doc Here:
http://www.smarty.net/docs/en/language.function.include.tpl
Example 7.45



Original issue reported on code.google.com by [email protected] on 22 Jun 2011 at 4:27

Attachments:

parse Error on Array

What steps will reproduce the problem?
1. Array.prototype.forEach = xxxx
2. assign $a = [1,2,3] 
3. {foreach $a as $i=>$v}  will show forEach.toString()

What is the expected output? What do you see instead?

==> pls use $a.length to loop


What version of the product are you using? On what operating system?

==> use asp3.0. //old but usefull



Original issue reported on code.google.com by [email protected] on 20 May 2011 at 5:35

Latest Safari update not parsing correctly

What steps will reproduce the problem?
Open http://noticiasmvs.com/ on an updated Safari. Templates are not parsing 
correctly.


What is the expected output? What do you see instead?
Expected output as shown on any other browser. Closing "}" are shown directly 
on the HTML in Safari.


What version of the product are you using? On what operating system?
Safari 7.0 (on MacOS 10.9) and Safari iOS 7.


Original issue reported on code.google.com by [email protected] on 23 Oct 2013 at 6:45

count_characters does not work anymore in 2.10

What steps will reproduce the problem?
1. Use the modifier in a template: {$number = $label|count_characters}
2. Use jSmart Version 2.10 (the modifier works in 2.9)

Firebug gives the following error:
Error: a.replace is not a function in count_characters(count_characters__p0)




Original issue reported on code.google.com by [email protected] on 9 Dec 2013 at 6:13

Support to run on SilkJS

This is more of a feature request but is there any chance of adding support for 
SilkJS this way not only could we have smarty support client side but could 
also have JS support on the server side using this and SilkJS.

Basic templates are working but using the {cycle} tag cause something to beak.

Original issue reported on code.google.com by [email protected] on 16 Apr 2012 at 4:37

null values return string null

What steps will reproduce the problem?
1.pass a parameter with null

What is the expected output? What do you see instead?
Expect output.. empty string

What version of the product are you using? On what operating system?
2.10

Please provide any additional information below.

Current solved with..

jSmart.prototype.registerPlugin(
      'modifier', 
      'nonulls', 
      function(s)
      {
         return (s === null ?  '' : s);
      }
   );

jSmart.prototype.addDefaultModifier('nonulls');


Original issue reported on code.google.com by [email protected] on 4 Apr 2014 at 11:08

"else if" not supported in jsmart templates

What steps will reproduce the problem?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>jSmart example</title>
    <script type="text/javascript" src="smart-2.9.min.js"></script>
</head>
<body>

<script id="test_tpl" type="text/x-jsmart-tmpl">
    {if (false)}
        a
    {else if (false)}
        b
    {else}
        c
    {/if}
</script>

<script type="text/javascript">
    var tpl = new jSmart(document.getElementById('test_tpl').innerHTML);
    var res = tpl.fetch();
    document.write( res );
</script>


</body>
</html>

What is the expected output? What do you see instead?

Expect: "c".  Actual: "b else c".

Original issue reported on code.google.com by [email protected] on 3 Apr 2013 at 3:14

If statement with 2 undefined variables incorrectly true

What steps will reproduce the problem?
var tpl = new jSmart('{if $condition && $condition2}OK{else}NOT OK{/if}');
var data = { 'condition': undefined, 'condition2': undefined };
var res = tpl.fetch(data);

What is the expected output? What do you see instead?
NOT OK

What version of the product are you using? On what operating system?
2.2

Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 2 Sep 2011 at 7:23

config_load fail

{config_load file="test.conf" section="setup"}

throw error"No config for test.conf"

test.conf is loacated in same direcorty as html page.

I didn't see ajax request,how it get this conf file?

Original issue reported on code.google.com by [email protected] on 20 Jul 2013 at 1:25

Undefined variables get converted to empty string

What steps will reproduce the problem?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>jSmart example</title>
    <script type="text/javascript" src="smart-2.9.min.js"></script>
</head>
<body>

<script id="test_tpl" type="text/x-jsmart-tmpl">
    {if isset($undefinedVar)}
        Variable is defined.
    {else}
        Variable is not defined.
    {/if}
</script>

<script type="text/javascript">
        function isset(val) { return (typeof val !== 'undefined'); }
    var tpl = new jSmart(document.getElementById('test_tpl').innerHTML);
    var res = tpl.fetch();
    document.write( res );
</script>


</body>
</html>

What is the expected output? What do you see instead?
Expected: Variable is not defined.
Actual: Variable is defined.


Please provide any additional information below.

The cause is that jsmart.js converts the undefined vars into empty string at 
line no. 1706 of jsmart.js (function name is getVarValue())
if (typeof val == 'undefined')
{
    return ''; // should have returned val;
}

Original issue reported on code.google.com by [email protected] on 12 Nov 2013 at 1:01

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.