Twig component renders incorrectly from the docs
See original GitHub issueSteps to reproduce the issue
- clone https://github.com/uandco/fractal-twig-issue
- run
npm install
- run
fractal start --sync
The navigation component shows up OK when viewed as a component or rendered via another component (I rendered it in the example component)
The rendering fails when rendered from the docs (HTML code is displayed). I tried to use the twig engine for docs too but get the same result.
Reproduces how often:
100%
Reduced test case
https://github.com/uandco/fractal-twig-issue
Context
- Fractal version: 1.3.0
- Node version: 10.15.1
- OS: MacOS 10.14.6
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (5 by maintainers)
Top Results From Across the Web
Why is this not rendered by the twig template? - Stack Overflow
Try in your config.yml. twig: paths: '%kernel.root_dir%/../src/Something/Bundle/SomethingBundle/Resources/public/templates': my_templates.
Read more >The flexible, fast, and secure template engine for PHP - Twig
Rendering Templates. To load a template from a Twig environment, call the load() method which returns a \Twig\TemplateWrapper instance:.
Read more >Emulating Components in Twig - DEV Community
When I work in Twig templates, not having access to bona fide components is definitely one of the things I miss most.
Read more >3 Ways to Reuse Twig Templates in Symfony | Scout APM Blog
Code for caching the templates is: $twig = new Twig_Environment($loader, ['cache' => '/templates/cache']); Filter, classifiers, and other ...
Read more >Working With Twig Templates - Drupal
When rendering an article node Drupal will first look for the node--article.html.twig template file and use it if it exists. If it doesn't, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If some HTML is indented and has an empty line before it, our markdown parser will convert that to a code block, for example:
In your component, your macro ends with a newline:
These newlines are also visible when viewing the component source in the browser.
To remove the newlines and fix the issue, an inline spaceless helper can be added to the
endmacro
tag:This will trim the ending newline from the macro output & fix the issue.
I’m trying to figure out why this is happening to some blocks of code and not others. I don’t have a huge sample size yet, but this only seems to be happening when the base templates (in my case Twig) are multi-line and have a for loop in them.