question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Needs Twig template adapter

See original GitHub issue

Currently twig.js can be used via the consolidate adapter, but it’s not great (no @handle includes etc).

A decent Twig adapter would really open up easier PHP implementations (plus Twig rocks 😉).

An adapter using the native PHP twig engine under the hood has been started here: https://github.com/LostKobrakai/twig but would also be nice to have one built around Twig.js (or one that let’s you choose which one to use?) so that PHP is not a required dependency.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:12

github_iconTop GitHub Comments

4reactions
jamiemagiquecommented, Feb 21, 2017

If anyone else comes across this, the fractal project has a twig adaptor: https://github.com/frctl/twig

I am currently using the 1.0.0-beta.1 successfully.

3reactions
adamnorwoodcommented, Mar 10, 2018

I was frustrated to discover that the Twig {{ path }} helper was working fine for me in the Web UI (over the localhost:3000 server), but inexplicably was set to null when building the static version, breaking my static asset paths. After digging through the Twig adapter source files, I realized that path is a filter. Not sure why this works differently for me compared to what’s in the documentation, and why it’s different than the suggested concatenation {{ path ~ '/css/main.css' }} fix mentioned above, but path now works consistently for me if I use it as a Twig filter like so:

{{ '/styles.css' | path }}

Full example of my preview markup:

<html>
    <head>
        <meta charset="utf-8">
        <title>{{ _target.title }}</title>
        <link rel="stylesheet" href="{{ '/styles.css' | path }}">
    </head>
    <body>
        {{ yield }}
    </body>
</html>

Hope that helps someone, or if anyone knows a better way to fix I’d be glad to know! FWIW, my Fractal build step is handled through Gulp (not sure if that matters).

Read more comments on GitHub >

github_iconTop Results From Across the Web

@frctl/twig - npm
An adapter to let you use Twig templates with Fractal. Requires Fractal v1.1.0 or greater. To install this adapter run this command:.
Read more >
markdown_to_html - Documentation - Twig - The flexible, fast ...
Twig - The flexible, fast, and secure template engine for PHP. ... composer require twig/markdown-extra. Then, on Symfony projects, install the ...
Read more >
Template engines - Fractal
If you don't need to customise the template engine adapter, you can just pass its package name into the .engine() method directly:.
Read more >
@wondrousllc/fractal-twig-drupal-adapter - npm package | Snyk
Twig template adapter for Fractal with Drupal 8 directives. For more information about how to use this package see ... Security review needed....
Read more >
Using Twig - mezzio - Laminas Docs
Twig is a template language and engine provided as a standalone component by SensioLabs. It provides: ... composer require mezzio/mezzio-twigrenderer ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found