Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate Twig best practices #4

Open
EvanLovely opened this issue Apr 28, 2017 · 3 comments
Open

Consolidate Twig best practices #4

EvanLovely opened this issue Apr 28, 2017 · 3 comments

Comments

@EvanLovely
Copy link
Contributor

@evanmwillhite Originally wrote:

If possible, it would be great to consolidate examples of Twig/PL best practices into a single location(s). I can see possibly either both documentation and a Drupal starter kit (a la Drupal-Lab) or possibly even just one of those?

The only place I could see this getting hairy is if we differ too much on implementation, but if we can agree enough it would be nice to provide a good starting point for people new to this:

  1. Pattern Lab installation inside of Drupal
  2. Integrating multiple kinds of PL files (atoms, molecules, etc.) into multiple kinds of Drupal files (fields, nodes, views, paragraphs, blocks, bricks, etc.)
@cybtachyon
Copy link

To me this feels like two separate topics:

Twig Coding Standards

Twig Patterns Best Practices

To that end, I had drafted https://github.com/cybtachyon/twig-standards a bit ago and would like to offer it up as a place to separate out Twig Coding Standards.

@evanmwillhite
Copy link

You're absolutely right @cybtachyon - sorry about the vague wording. I meant specifically the implementation used within component-based theming using include, extends or embed. I often get questions about how to integrate Pattern Lab components with views, paragraphs, blocks (fill-in-the-blank Drupal thing), so I was talking about that specific piece.

That said though, thanks for sharing your Twig Coding Standards. I'll be sharing with our team - this is awesome!

@sghoweri
Copy link

sghoweri commented May 2, 2017

While I personally think a catch-all "Twig/PL best practices" is a bit too broad, I could see a ton of value diving into several sub-topics / reoccurring themes through real world code examples, example plugin configurations, sample code snippets, dos and don'ts, known issues or workarounds, etc.

High level topics:

  • Twig templating in general (PL and Drupal agnostic):
  • Pattern Lab --> Drupal Insights (making PL work better w/ Drupal)
  • Drupal --> Pattern Lab Insights (making Drupal play nicely with PL)

As a quick brain dump:

  1. General Twig coding standards (ie. how to write clean code that doesn't stink) -- like the coding standards doc @cybtachyon put together.
  2. Sample real world code using includes, embeds and extends (especially the latter two which don't seem to have a whole lot of examples out there) but also strategies on getting Pattern Lab isms w/ Twig extensions playing nicely with Drupal
  3. Common Twig hiccups (converting data, merging, setting data and data validation, cascading data / inheritance), especially with D8's Attributes object + ways this can be handled (using plugins but also other approaches)
  4. Ideas on some good component patterns / conventions (naming conventions for variables, nesting templates, handling template variations includes vs extends vs embeds on a single _template.twig, etc). Highly opinionated but examples of options could be helpful nonetheless. Folder structure / organization. Single folder containing all pattern files vs multiple folders per type.
  5. Real world examples on extending out of the box Twig functionality (functions, filters, custom tags, actual examples of writing Twig tests...) -- very few examples out there, let alone examples in the context of PL + Drupal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants