Skip to content

Undefined variables get converted to empty string #33

Description

@GoogleCodeExporter
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 arora.gu...@gmail.com on 12 Nov 2013 at 1:01

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions