定制 phile/twig-filters 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

phile/twig-filters

Composer 安装命令:

composer require phile/twig-filters

包简介

An example plugin for Phile showing how to make Twig filters.

关键字:

README 文档

README

Build Status

Adds helpfull Twig functions to Phile and easily allows you to create new ones. Project home.

Installation

composer require phile/twig-functions

Activation

$config['plugins']['phile\\twigFunctions'] = [
    'active' => true
];

Usage

This plugin includes some predefined Twig-filter and allows you to easily add your own.

Define a New Custom Filter

See the existing filters in config.php for how to add your own filter.

excerpt

Grabs the first paragraph of the content string.

{{ content|excerpt }}

limit_words

Similar to excert but limits on number of words. Use Twig's striptags to remove HTML-tags.

{{ page.content|striptags|limit_words }}

shuffle

Shuffles an array. For example show a shuffled lists of pages:

<ul class="posts">
  {% for page in pages|shuffle %}
    <li><a href="{{ page.url }}">{{ page.title }}</a></li>
  {% endfor %}
</ul>

slugify

This new Twig filter allows you to slugify a string. This is useful for making safe URLs, HTML-safe class/id names, or just cleaning up general strings.

<!-- becomes "this–is–an–strange–string" -->
{{ "This Is ____an STRÄNGE      string" | slugify }}

统计信息

  • 总下载量: 66
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 7
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-04-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固