wp-hibou/template

此包已被弃用且不再维护。作者建议使用alpipego/awp-template包代替。

wp.template和locate_template加载器

0.4.0 2017-11-24 10:40 UTC

This package is not auto-updated.

Last update: 2022-02-01 13:09:27 UTC


README

为wp.template和locate_template的可重用模板提供WordPress模板加载器

使用方法

通过直接实例化或使用TemplateFactory的build方法获取Template实例。

/**
 * Template constructor.
 *
 * @param array $template Uses `locate_template` to prioritize templates @see locate_template()
 * @param string $name Id passed to `wp.template`
 * @param array $data optional array of unchanging data
 */
 public function __construct(array $template, string $name, array $data = [])

将数组(可能为空)传递给Template的render方法以渲染PHP模板。要渲染wp.template,请不传递任何内容。