What's on this page
CSS, JavaScript and processing
Cecil provides Twig filters to compile Sass, minify, fingerprint, inline or embed CSS and JavaScript assets.
fingerprint
Add the file content finger print to the file name.
{{ asset(path)|fingerprint }}
{{ path|fingerprint }}
Examples:
{{ asset('styles.css')|fingerprint }}
minify
Minifying a CSS or a JavaScript file.
{{ asset(path)|minify }}
Examples:
{{ asset('styles.css')|minify }}
{{ asset('scripts.js')|minify }}
minify_css
Minifying a CSS string.
{{ variable|minify_css }}
{% apply minify_css %}
{# CSS here #}
{% endapply %}
Examples:
{% set styles = 'some CSS here' %}
{{ styles|minify_css }}
<style>
{% apply minify_css %}
html {
background-color: #fcfcfc;
color: #444;
}
{% endapply %}
</style>
minify_js
Minifying a JavaScript string.
{{ variable|minify_js }}
{% apply minify_js %}
{# JavaScript here #}
{% endapply %}
Examples:
{% set script = 'some JavaScript here' %}
{{ script|minify_js }}
<script>
{% apply minify_js %}
var test = 'test';
console.log(test);
{% endapply %}
</script>
scss_to_css
Compiles a Sass string to CSS.
{{ variable|scss_to_css }}
{% apply scss_to_css %}
{# SCSS here #}
{% endapply %}
Alias: sass_to_css.
Examples:
{% set scss = 'some SCSS here' %}
{{ scss|scss_to_css }}
<style>
{% apply scss_to_css %}
$color: #fcfcfc;
div {
color: lighten($color, 20%);
}
{% endapply %}
</style>
to_css
Compiles a Sass file to CSS.
{{ asset(path)|to_css }}
{{ path|to_css }}
Examples:
{{ asset('styles.scss')|to_css }}
inline
Outputs the content of an Asset.
{{ asset(path)|inline }}
Example:
{{ asset('styles.css')|inline }}
dataurl
Returns the data URL of an asset.
{{ asset(path)|dataurl }}
{{ asset(image_path)|dataurl }}