wolnosciowiec / content-compiler-bundle

将所有内容转换为HTML

安装: 75

依赖项: 0

建议者: 0

安全性: 0

星标: 1

关注者: 3

分支: 0

类型:symfony-bundle

dev-master 2017-06-03 12:31 UTC

This package is not auto-updated.

Last update: 2024-09-29 01:46:11 UTC


README

将所有内容转换为HTML,包括从Markdown到HTML的转换。

简单来说,它是一个用于HTML转换的接口,并附带了一些示例实现。

/*
 * Wolnościowiec / ContentCompilerBundle
 * -------------------------------------
 *
 *   Converts everything to HTML, including conversion from Markdown to HTML.
 *   A part of an anarchist portal - wolnosciowiec.net
 *
 *   Wolnościowiec is a project to integrate the movement
 *   of people who strive to build a society based on
 *   solidarity, freedom, equality with a respect for
 *   individual and cooperation of each other.
 *
 *   We support human rights, animal rights, feminism,
 *   anti-capitalism (taking over the production by workers),
 *   anti-racism, and internationalism. We negate
 *   the political fight and politicians at all.
 *
 *   http://wolnosciowiec.net/
 *
 *   License: LGPLv3
 */

设置

  1. 添加到 AppKernel
  2. 作为服务使用 :-)

示例

// twig
var_dump($this->contentCompilerFactory
     ->getContentCompiler('twig')
     ->compileFromString('Monkeys are eating {{ fruitName }}', false, [
         ContentCompilerInterface::VARIABLES => ['fruitName' => 'banana'],
     ])
);

// markdown
var_dump($this->contentCompilerFactory
     ->getContentCompiler('markdown')
     ->compileFromString('# Bananas are everywhere')
);