定制 mbaynton/csv4twig 二次开发

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

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

mbaynton/csv4twig

最新稳定版本:1.0.1

Composer 安装命令:

composer require mbaynton/csv4twig

包简介

A CSV escaping filter for the Twig templating engine.

README 文档

README

CSV escaping filter for the Twig templating engine

Build Status

CSV4Twig enables Twig templates to generate safe, properly-escaped CSV output. It's useful when you need to get CSV reports out of an existing application that has a Twig-enabled output layer.

Usage

  1. Add it to your project with composer:
    composer require mbaynton/csv4twig:1.0.*

  2. Tell Twig about it. You'll need to get a hold of the \Twig_Environment instance that will generate the CSV; then just pass it to \mbaynton\CSV4Twig\Filter::registerFilters().

  3. Use it in your template with the autoescape tag:

    {% autoescape "csv" %}
    {{ some_value }},{{ another_value }}
    {% endautoescape %}
    

    The contents of some_value and another_value will be escaped using the default CSV-escaping conventions of PHP's fputcsv() function. fputcsv() is the function this filter uses internally.

    If you prefer, you can also escape certain values explicitly:

    {% autoescape false %}
    {{ some_value|e("csv") }},{{ another_value }}
    {% endautoescape %}
    

That's it!

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-10-20