一键导入
drupal-twig
Drupal Twig templates — best practices, auto-escaping, translation, library attaching, debugging, and SDC components.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Drupal Twig templates — best practices, auto-escaping, translation, library attaching, debugging, and SDC components.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
HTMX in Drupal 11.3+ core — the Htmx PHP fluent builder, dynamic forms with swapOob, partial routes with _htmx_route, response headers, and Drupal.behaviors integration. Use when building interactive UI without full-page reloads using Drupal's native HTMX support.
DDEV local development expertise. Use when working with DDEV projects, containers, configuration, or troubleshooting DDEV environments.
Custom Docker Compose local development patterns. Use when working with Docker-based local environments, container configuration, or troubleshooting Docker setups.
Drupal access control — permissions.yml, access callbacks, AccessResult, custom access checkers, and entity access.
Drupal Cache API — cache tags, contexts, max-age, cache bins, invalidation, and adding cache metadata to render arrays.
Drupal Composer management — requiring modules, updates, patches via composer-patches, and version constraints.
| name | drupal-twig |
| description | Drupal Twig templates — best practices, auto-escaping, translation, library attaching, debugging, and SDC components. |
|escape unless you know the source{% trans %} for all user-facing strings{{ attach_library() }} for CSS/JS — never inline{# Simple string #}
{% trans %}Hello world{% endtrans %}
{# With variable #}
{% trans %}Hello {{ name }}{% endtrans %}
{# Plural #}
{% trans %}
@count item
{% plural count %}
@count items
{% endtrans %}
{{ attach_library('my_module/my-library') }}
{{ attach_library('mytheme/component-name') }}
{# Already sanitized by Drupal — safe to use |raw #}
{{ content.body }}
{{ content|raw }}
{# Render a single field #}
{{ content.field_image }}
{# Render with a specific view mode #}
{{ node|view('teaser') }}
{# Dump variables (requires Twig debug enabled) #}
{{ dump(content) }}
{{ dump(node) }}
{{ dump(_context|keys) }}
{# Node template #}
{{ node.title.value }}
{{ node.bundle() }}
{{ node.id() }}
{{ node.isPublished() }}
{# Check if field is set #}
{% if content.field_image|render %}
{{ content.field_image }}
{% endif %}
{# Field items loop #}
{% for item in node.field_tags %}
{{ item.entity.name.value }}
{% endfor %}
{# Use a component #}
{% include 'mytheme:button' with {
label: 'Click me',
url: path('entity.node.canonical', {node: node.id()}),
variant: 'primary',
} %}
#[Hook('theme_suggestions_node_alter')]
public function themeSuggestionsNodeAlter(array &$suggestions, array $variables): void {
$node = $variables['elements']['#node'];
$view_mode = $variables['elements']['#view_mode'];
$suggestions[] = 'node__' . $node->bundle() . '__' . $view_mode;
}