Several Handlebars.js spec templates render differently in 3.0.1
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 57/100
Research direction
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.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- PHP
- Stars
- 77
- Forks
- 34
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from salesforce/handlebars-php
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
salesforce/handlebars-php#25 · 2 comments · 2 reactions ·
-
rendering with strict=true does not throw for missing nested variables in contextPossibly taken @hubermat claimed this 1151 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 25/100
salesforce/handlebars-php#23 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
salesforce/handlebars-php#22 · 2 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
salesforce/handlebars-php#21 · 1 comment · 4 reactions ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
salesforce/handlebars-php#11 · 1 comment ·
All issues in salesforce/handlebars-php
Similar issues
-
bug good first issue small
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
open-telemetry/opentelemetry-php#2164 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
-
sync-en
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 2 days
-
Перевод устарел
Difficulty 1/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Documentation
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day