Hanjst Loading... 汉吉斯特加载中...
Hanjst {include file="$pageheader"} {include file="$model"} {$i=Math.random()} {var $jstr='this is a j string'}

....

Hanjst特征/Features


{foreach $newscontentlist as $page} {foreachelse} {/foreach}

....

Hanjst样例/Demo


"$" is a speical and default tag served as a prefix marker for a variable in Hanjst.

Try to call a func named 'aFunc':
{$aFunc($i)}

"aFunc" is an user-defined function with JavaScript.
"$aFunc($i)" is to call aFunc and display its return value.

Similarly, "$alist[$i]" or "$alist[$i][$j]" is to display an element with $i as its key in a hash or array object.

Call a built-in func:
{$jstr.substring(0, 12)}
"substring" is a built-in function for JavaScript.
"jstr" is a variable from server response, which will be accessed via $jstr.

"$jstr" is to display the variable "jstr".
"$jstr.substring(0, 12) is to shorten the string for first 12 bytes and/or chars, then display the modified $jstr.

Give random numbers with while: {while $i<5}
  • line {$i}
  • {$i++} {whileelse}
  • Out of While.
  • {/while}
    ....

    2nd, try to list an associative list: {for var $k in $userlist}

  • Id:{$userlist[$k]['id']}, Name:{$userlist[$k]['name']}
  • {forelse}
  • No more User Data.
  • {/for}

    3rd, try to list an associative list: {foreach $userlist as $k}
  • {$k} Id:{$userlist[$k]['id']}, Name:{$userlist[$k]['name']}
  • {/foreach}

    Try to branch-if-else: {$i=Math.random()} {if $i < 0.3}

  • {$i} is lt 0.3
  • {else if $i<0.5 }
  • {$i} is lt 0.5
  • {else}
  • {$i} is gt 0.5
  • {/if}


    Try literal:
    {literal} {if $user['feedback'] == 2} {$user['age']} {/if} {/literal}

    This is A SPAN with embedded Tpl sentence.
    This is a name. This is a name, 2nd.
    This is a span, 2nd.


    Due to limitations of embedded tags in an HTML element,
    we introduce "lt" as less than (<) , "gt" as greater than(>) and "eq" as equal(=).


    Hanjst @ Github
    Hanjst Document and API 在线文档
    Hanjst Blog 汉吉斯特博客文档

    本页样例可以通过查看 HTML 代码进行翻阅. {$num=123.456} {$parseInt($num)} {$newsList=[]} {$newsList[0]=new Object()} {$newsList[0]['id']=12} {$newsList[0]['title']='News-Title-12'} {$newsList[1]=new Object()} {$newsList[1]['id']=34} {$newsList[1]['title']='News-Title-34'}

    {$title='Hello Wordl!'} {$titleLength=$title.length}

    {if $titleLength > 50} {$titleLength} is greater than 50! {else if $titleLength > 10} {$titleLength} is greater than 10! {else} {$titleLength} is less than 10! {/if}



    {include content="$pagefooter"}