mrjmd / pdb

Decoupled Blocks is a Drupal 8 module to simplify integrating javascript frameworks into your site.
https://www.drupal.org/sandbox/mrjmd/2664138
57 stars 14 forks source link

[META] Twig integration #15

Open mrjmd opened 8 years ago

mrjmd commented 8 years ago

Twig templates are the Drupal standard. We should definitely support twig-based components out of the box, but there are several possible ways this could be integrated.

Does it need its own framework-defining sub module, or should it be included by default? What about other frameworks that may want to build on top of twig templates (ng2-twig integration is happening but the details remain murky at this point)?

mrjmd commented 8 years ago

Capturing some of my discovery work here:

https://github.com/twigjs/twig.js <-- likely to be relevant to any twig communication with the client side. Also this twig.js library appears to be used in the existing integration of Angular 2 and Twig templates, which can be found here:

https://github.com/acquia/js-exploration/tree/angular2-twig-exploration

We'll need to either do more digging or reach out directly to those involved in the JS Exploration work to get full details on that integration.

mrjmd commented 8 years ago

I did get more details about the existing twig / ng2 template integration and, as I've written about elsewhere, while interesting it is not an ideal solution.

Instead I propose that initial twig integration should be put directly into the main pdb module, and involve the ability to add twig template files to a component's info.yml file. These files by default should be rendered server side by Drupal as any other twig template would be.

kenneth-bolivar-castro commented 8 years ago

@mrjmd don't get my wrong, but I cannot see why we should create integration with twig to be render for Drupal since the main idea here it's to build a decoupled solution for JS frameworks

ghost commented 8 years ago

@kenneth-bolivar-castro As far as I'm aware, this wouldn't be Drupal-specific Twig. It would be generic Twig, which fits well with other uses of JS components as part of apps that use twig, such as mobile apps or even node.js apps.

I would like to think at some point that you could make a stand-alone component with JS, Twig, etc. that could be used in any of those apps, including Drupal.

mrjmd commented 8 years ago

My two cents: The idea is that, at its root, the main pdb module is essentially a "component API". A decoupled block is a component written in its own directory with a corresponding info.yml file that declares its existence to Drupal, and lists whatever js, css, and template assets are needed to make it work.

For the most part, people will likely be building components that leverage a specific javascript framework, but there are use cases for simply componentizing css and template files. Essentially this would be a way to write a custom block module without writing any of the scaffolding code, you'd just write your component, add your info.yml file, and place your block.

The level of effort here should be low, but I'm open to whether this should go in the main pdb module or be another sub-module.