视图上的把手不显示数据

时间:2015-12-24 09:59:49

标签: php jquery handlebars.js mustache

我在php项目中创建了一个文件base.tpl。我想用把手显示数据,但我只得到一个空白页面。你能帮我吗 ? 我的代码:

<html>
<head>
  <title>HandleBar Features</title>
</head>
<body>
<script id="shoe-template" type="x-handlebars-template">
{{#people}}
<li class="shoes">
    <p>{{name}}</p>
</li>
{{/people}}
</script>
<ul class="shoesNav">
</ul>

<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="application/javascript" src="https://cdnjs.cloudflare.com   /ajax/libs/handlebars.js/4.0.5/handlebars.min.js"></script>
<script type="text/javascript">
$( document ).ready(function() {
    var data = {
        people: [
            {name: "Alan"},
            {name: "Allison"},
            {name: "Ryan"}
        ],
        empty: [ ]
    };

    var theTemplateScript = $('#shoe-template').html();
    var theTemplate = Handlebars.compile(theTemplateScript);
    $('.shoesNav').append(theTemplate(data));
});
</script>
</body>
</html>

我得到一个空白页的错误,我不明白我的问题在哪里。提前告诉我,对不起我的英文

2 个答案:

答案 0 :(得分:0)

你的handlebar.js src src="https://cdnjs.cloudflare.com /ajax/libs/h中有一个空格。请删除它,它应该工作:

<html>
<head>
  <title>HandleBar Features</title>
</head>
<body>
<script id="shoe-template" type="x-handlebars-template">
{{#people}}
<li class="shoes">
    <p>{{name}}</p>
</li>
{{/people}}
</script>
<ul class="shoesNav">
</ul>

<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="application/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.5/handlebars.min.js"></script>
<script type="text/javascript">
$( document ).ready(function() {
    var data = {
        people: [
            {name: "Alan"},
            {name: "Allison"},
            {name: "Ryan"}
        ],
        empty: [ ]
    };

    var theTemplateScript = $('#shoe-template').html();
    var theTemplate = Handlebars.compile(theTemplateScript);
    $('.shoesNav').append(theTemplate(data));
});
</script>
</body>
</html>

答案 1 :(得分:0)

foreach-loops的官方语法是:

import threading
import time

t1 = threading.Lock()
cond = threading.Condition(t1)

class myThread (threading.Thread):
    def __init__(self, threadID, name, counter):
        threading.Thread.__init__(self)
        self.threadID = threadID
        self.name = name
        self.counter = counter
    def run(self):
        print "Starting " + self.name
        t1.acquire()
        cond.wait(10)`enter code here`
        t1.release()
        print "%s,%s,%s" % (self.name, self.counter, 3)


# Create new threads
thread1 = myThread(1, "Thread-1", 1)

# Start new Threads
thread1.start()

time.sleep(2)
t1.acquire()
cond.notify_all()

希望,这有帮助!