JS API: Call a pattern from JavaScript

Created on 31 October 2022, over 2 years ago
Updated 19 January 2023, over 2 years ago

Problem/Motivation

The same way we can call a pattern from Twig template with {{ pattern() }}, would it be possible to have the same API for JavaScript?

In UI Suite Bootstrap, I am starting to have the need for example in https://git.drupalcode.org/project/ui_suite_bootstrap/-/blob/5.0.x/asset... there could be calls to 2 patterns instead of reproducing the pattern HTML in JavaScript.

Proposed resolution

The same way there is Drupal.theme, automatically provide a Drupal.ui_patterns.pattern() or Drupal.ui_patterns.[pattern_id]().

Maybe there are solutions that already exist, because we should use the backed rendering to still benefits from the exact Twig template and potential preprocess.

Remaining tasks

API changes

💬 Support request
Status

Active

Version

1.0

Component

Code

Created by

🇫🇷France Grimreaper France 🇫🇷

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024