Kaynağa Gözat

works with empty sections

tags/0.4.0
Ben Cherry 15 yıl önce
ebeveyn
işleme
d5e54b409a
5 değiştirilmiş dosya ile 18 ekleme ve 19 silme
  1. +7
    -7
      examples/two_sections.html
  2. +4
    -1
      examples/two_sections.js
  3. +3
    -3
      examples/two_sections.txt
  4. +1
    -1
      mustache.js
  5. +3
    -7
      test/mustache_spec.rb

+ 7
- 7
examples/two_sections.html Dosyayı Görüntüle

@@ -1,7 +1,7 @@
{{#show_following}}
{{/show_following}}
{{#show_following}}
{{/show_following}}
{{#foo}}
BAR
{{/foo}}
BAR
{{^bar}}
BAR
{{/bar}}

+ 4
- 1
examples/two_sections.js Dosyayı Görüntüle

@@ -1 +1,4 @@
var two_sections = {};
var two_sections = {
foo: true,
bar: false
};

+ 3
- 3
examples/two_sections.txt Dosyayı Görüntüle

@@ -1,3 +1,3 @@
BAR bar
BAR bar
BAR bar
BAR
BAR
BAR

+ 1
- 1
mustache.js Dosyayı Görüntüle

@@ -149,7 +149,7 @@ var Mustache = function() {

var that = this;
var regex = new RegExp("(?:^([\\s\\S]*?))?" + this.otag + "(\\^|\\#)\\s*(.+)\\s*" + this.ctag +
"\n*([\\s\\S]+?)" + this.otag + "\\/\\s*\\3\\s*" + this.ctag + "\\s*" +
"\n*([\\s\\S]*?)" + this.otag + "\\/\\s*\\3\\s*" + this.ctag + "\\s*" +
"([\\s\\S]*?)(?=(?:" + this.otag + "(?:\\^|\\#)\\s*(?:.+)\\s*" + this.ctag + ")|$)", "g");

// for each {{#foo}}{{/foo}} section do...


+ 3
- 7
test/mustache_spec.rb Dosyayı Görüntüle

@@ -92,22 +92,18 @@ describe "mustache" do
run_js(js).strip.should == "foo BAR"
end

it "should not suck" do
it "should work with empty sections" do
js = <<-JS
try{
#{@boilerplate}

print(Mustache.to_html("{{#foo}}\\
{{/foo}}\\
{{#bar}}\\
{{/bar}}\\
", {}));
print(Mustache.to_html("{{#foo}}{{/foo}}foo{{#bar}}{{/bar}}", {}));
} catch(e) {
print(e);
}
JS

run_js(js).should == "foanfs"
run_js(js).strip.should == "foo"
end




Yükleniyor…
İptal
Kaydet