Download the PHP package edgedesign/texy-bundle without Composer
On this page you can find all versions of the php package edgedesign/texy-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download edgedesign/texy-bundle
More information about edgedesign/texy-bundle
Files in edgedesign/texy-bundle
Package texy-bundle
Short Description Edgedesign Texy! bundle
License MIT
Informations about the package texy-bundle
EdgeDesign Texy Bundle
This is a simple bundle wrapping up Texy! text processor (http://texy.info/en) into a Symfony bundle.
Setup
composer require edgedesign/texy-bundle
- Add
new Edge\TexyBundle\EdgeTexyBundle()
to your AppKernel.
Configuration
Feel free to override Resources/config/config.yml
directives.
You can change classes which will be instantiated, if you are not satisfied with our implementation,
just implement correct interfaces please.
Custom attributes
In section edge_texy_bundle.custom_attributes
you can define custom html attributes which will
be added to every html element. Useful for allowing html5 attributes (download
, data-something
, ...).
Filters
In section edge_texy_bundle.filters
you can set-up your filters.
First-level key determines name of filter.
Then, there are 3 types of settings.
- 'allowed' is used for setting enabled modules via calls like
$texy->allowed[$moduleName] = true/false
- 'module' is for passing settings to module, it will be translated in call similar to this:
$texy->$moduleName.'Module'->$parameter = $settings
- 'variables' is the most powerful settings, it enables you to do almost everything. It is translated into following call:
$texy->$variableName = $variableValue
In values, you can use asterisk sign (*), which will be translated to constant Texy::ALL and dash sign (-), which translates to Texy::NONE.
If this settings is not enough, you can extend Texy, set it up in constructor and set name of your instance as class
attribute.
In this case, settings allowed, module and variables will be passed to this extended class too.
Usage
There are two ways how to use this bundle.
Service
You can get TexyProcessor service named edge_texy.processor
and call method
This will process your $text
via filter set in config with id $filterId
.
Twig
Second way is to use registered Twig macros 'texy_process
' and 'texy_process_line
'.
Alternative Twig syntax useful when you don't have the content stored in variable, but in template itself:
(Thank you, OndraM, for pointing that out.)
This way, given variable is passed through filter named filterId
. If no filter name given, macro tries to use filter called "default".
Difference between macros is that when using texy_process_line, Texy will not wrap given code in block tags like
.
Example config.yml
Settings example for sanitizing html output (put this into your config.yml):
Now, you can use filter sanitize
to sanitize your HTML output from user
and filter strip
to make user no HTML from user will appear in your code.