SCSS/LESS Editor Field
Created 7 years ago by psaunders

I have a custom LESS field attached to post to push out to the front end. How do you get the code to actually be processed so that it can either be added to a bundle, or, parsed inline in a twig file.

    {{ post.style.parse }}
    {{ post.style|raw }}
    {{ post.style.render }} // 500s hunting for some file

The obvious ones above don't work

ryanthompson  —  7 years ago Best Answer

You'll need to add it to an asset collection so use the EditorFieldTypePresenter class in the editor field type to get the path to add to an asset collection:

{{ asset_add('styles.css', post.style.path) }}
piterden  —  7 years ago

What do you have in output?

psaunders  —  7 years ago

It just renders it out with no preprocessing so:

.thing{
    .stuff{
    }
}

Comes out instead

piterden  —  7 years ago

You could add it to assets. Try to play with Assetic. Look at StreamsPlugin class to see what functions of Assetic available inside twig.

ryanthompson  —  7 years ago Best Answer

You'll need to add it to an asset collection so use the EditorFieldTypePresenter class in the editor field type to get the path to add to an asset collection:

{{ asset_add('styles.css', post.style.path) }}