Skip to content

trzmaxim/twig-inline-styles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

twig-inline-styles

Twig extension for create and output inline styles

Installation

Through Composer

composer require "trzmaxim/twig-inline-styles": "dev-master"
use TrzMaxim\TwigInlineStyles\InlineStylesExtension;

$twig = new Twig_Environment(...);

$twig->addExtension(new InlineStylesExtension());

Usage

Styles are presented in the form of a hash. Style keys are camelCase, vendor prefix must begin with a capital letter (WebkitTransition). The value is a string or a number to the number of automatically adds the line "points", but there are exceptions (see)

{% style foo {
  fontSize: 12,
  color: 'red'
} %}

<p style="{{ foo }}"></p>

Styles can be merged by .merge

{% style foo {
  fontSize: 12,
  color: 'red'
} %}

{% style bar {
  color: 'green',
  padding: '10px 0',
} %}

{{ foo.merge(bar) }} {# font-size:12px;color:green;padding:10px 0; #}

About

Twig extension for create and output inline styles

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages