
內容簡介
功能特色
為可配置的文章類型添加元框,以建立並編輯 Twig 模板
為 WP 主題和外掛程式編輯器添加 Twig 支援
甚至可以自訂 CodeMirror 主題
外掛相依性
如何使用元框功能
本外掛使用在 Timber::$locations 中定義的路徑作為模板路徑,如果沒有提供,則回退到上傳資料夾。
請使用以下方式調整您的 Timber::render('page.twig', $context) 函式:
$filenames = [TimberEditor::getTemplateFilename(), 'page.twig'];
Timber::render($filenames, $context);
或是使用以下方式:
TimberEditor::render('page.twig', $context);
# 如果當前文章的模板不存在,則 'page.twig' 作為回退
或是使用以下方式:
TimberEditor::renderPost('page.twig', $context);
# renderPost() 自動將 ['post' => new Timber\Post()] 加入 $context
外掛標籤
開發者團隊
原文外掛簡介
Features
adds a metabox to configurable Post-Types to create and edit Twig templates
adds Twig support to the WP Theme & Plugin editors
you can even customize the CodeMirror theme
Plugin Dependencies
How to use the MetaBox Feature
The plugin uses the path defined in Timber::$locations as the templates path or falls back to the uploads folder if none is provided.
Either adjust your Timber::render('page.twig', $context)-functions like this:
$filenames = [TimberEditor::getTemplateFilename(), 'page.twig'];
Timber::render($filenames, $context);
like this
TimberEditor::render('page.twig', $context);
# 'page.twig' serves as a fallback if the current posts's template doesn't exist
or like this
TimberEditor::renderPost('page.twig', $context);
# renderPost() automatically adds ['post' => new Timber\Post()] to the $context
