You are here

class Extension in Markdown 8.2

Twig Markdown Extension.

Hierarchy

  • class \Drupal\markdown\Twig\Extension extends \Drupal\markdown\Twig\Twig_Extension implements \Drupal\markdown\Twig\Twig_Extension_GlobalsInterface

Expanded class hierarchy of Extension

1 string reference to 'Extension'
markdown.services.yml in ./markdown.services.yml
markdown.services.yml
1 service uses Extension
twig.extension.markdown in ./markdown.services.yml
Drupal\markdown\Twig\Extension

File

src/Twig/Extension.php, line 10

Namespace

Drupal\markdown\Twig
View source
class Extension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface {

  /**
   * An instance of a markdown processor to use.
   *
   * @var \Drupal\markdown\MarkdownInterface
   */
  protected $markdown;

  /**
   * {@inheritdoc}
   */
  public function __construct(MarkdownInterface $markdown) {
    $this->markdown = $markdown;
  }

  /**
   * {@inheritdoc}
   */
  public function getName() {
    return 'markdown';
  }

  /**
   * {@inheritdoc}
   */
  public function getGlobals() {
    return [
      'markdown' => $this->markdown,
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function getFilters() {
    return [
      'markdown' => new \Twig_SimpleFilter('markdown', [
        $this->markdown,
        'parse',
      ], [
        'is_safe' => [
          'html',
        ],
      ]),
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function getFunctions() {
    return [
      'markdown' => new \Twig_SimpleFunction('markdown', [
        $this->markdown,
        'parse',
      ], [
        'is_safe' => [
          'html',
        ],
      ]),
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function getTokenParsers() {
    return [
      new TokenParser($this->markdown),
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Extension::$markdown protected property An instance of a markdown processor to use.
Extension::getFilters public function
Extension::getFunctions public function
Extension::getGlobals public function
Extension::getName public function
Extension::getTokenParsers public function
Extension::__construct public function