Several Handlebars.js spec templates render differently in 3.0.1

Đang mở
#32 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
57/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
php
Lĩnh vực
compilers

Hướng nghiên cứu

This is ten independent rendering defects: reproduce them one at a time with a short PHP script after composer install, starting with the simplest case (\{{foo}} escaping) to find where the lexer/parser handles escapes, then move to block helpers (#if includeZero, #with else and block params), lookup, @root, zero paths and partial indentation. The parser, Handlebars\Template and Handlebars\Compiler classes carry most of these paths, so read them before touching anything. Add the ten cases as tests first, since the issue is effectively a fixture list. Done means each template renders the expected string and the new tests pass.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

I ran some of Handlebars.js 4.7.10's spec cases through salesforce/handlebars-php 3.0.1 (Packagist, d3a0552d85472249617ef6b56197c844d62d2ac3) and master (0dd1690a5c1fdb785f5d77e4010a240f9eb9d7d7). These ten render differently from Handlebars.js on both. I left out the documented v1.1 data-variable differences and anything already covered by #3, #6, #25 or #26.

{{#if true}} with a boolean literal (blocks.js, "should handle nesting")
Template {{#data}}\n{{#if true}}\n{{.}}\n{{/if}}\n{{/data}}\nOK., data {"data":[1,3,5]}. Expected 1\n3\n5\nOK., got OK.

lookup helper (builtins.js, "should lookup arbitrary content")
Template {{#each goodbyes}}{{lookup ../data .}}{{/each}}, data {"goodbyes":[0,1],"data":["foo","bar"]}. Expected foobar, got an empty string.

includeZero on #if (builtins.js, #if)
Template {{#if goodbye includeZero=true}}GOODBYE {{/if}}cruel {{world}}!, data {"goodbye":0,"world":"world"}. Expected GOODBYE cruel world!, got cruel world!

{{^}} inverse inside a block (blocks.js, "block inverted sections")
Template {{#people}}{{name}}{{^}}{{none}}{{/people}}, data {"none":"No people"}. Expected No people, got an empty string.

#with block parameters (builtins.js, "with provides block parameter")
Template {{#with person as |foo|}}{{foo.first}} {{last}}{{/with}}, data {"person":{"first":"Alan","last":"Johnson"}}. Expected Alan Johnson, got a single space.

#with ... {{else}} (builtins.js, "with with else")
Template {{#with person}}Person is present{{else}}Person is not present{{/with}}, data {}. Expected Person is not present, got both branches: Person is presentPerson is not present.

\{{ escaped mustache (basic.js, escaping)
Template \{{foo}}, data {"foo":"food"}. Expected the literal {{foo}}, got \food.

@root from runtime data (data.js, "passed root values take priority")
Template {{@root.foo}}, context {"foo":"should not be used"}, runtime data.root {"foo":"hello"}. Expected hello, got an empty string.

Zero through a nested path (basic.js, zeros)
Template num: {{num1/num2}}, data {"num1":{"num2":0}}. Expected num: 0, got num: .

Standalone partial indentation (partials.js, "indented partials")
Template Dudes:\n{{#dudes}}\n {{>dude}}\n{{/dudes}}, partial dude = {{name}}\n, data {"dudes":[{"name":"Yehuda","url":"http://yehuda"},{"name":"Alan","url":"http://alan"}]}. Expected Dudes:\n Yehuda\n Alan\n, got Dudes:\nYehuda\nAlan\n. The nested indented partials case behaves the same way.

Happy to turn any of these into test cases for the repo if that's useful.

Ngôn ngữ chính
PHP
Star
77
Fork
34
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của salesforce/handlebars-php

Tất cả issue của salesforce/handlebars-php

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.