Skip to content

Collect dynamic CSS in Craft Twig templates and add it to the master template

License

Notifications You must be signed in to change notification settings

craftedsystems/craft--dynamic-css

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Craft Dynamic CSS Plugin

Collect dynamic CSS in Craft Twig templates and output them in the master template.

Add CSS in Nested Blocks

{% set style %}
  #{{ id }} {
    color: {{ block.textColor }};
    background-color: {{ block.backgroundColor }};
  }
{% endset %}
{{ craft.dynamiccss.set(style) }}

You can call set multiple times. All styles will be concatenated.

Output CSS in Master Template

{% if craft.dynamiccss.get() != '' %}
  <style>
    {{ craft.dynamiccss.get() }}
  </style>
{% endif %}

About

Collect dynamic CSS in Craft Twig templates and add it to the master template

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages