Take the 2-minute tour ×
Tridion Stack Exchange is a question and answer site for Tridion developers and administrators. It's 100% free, no registration required.

Is there any way to get Tridion and SASS to work together nicely? e.g. I upload my .scss files and they are automatically converted into css files when I publish or create a component presentation?

Is there a best practice/tool/add-on which could facilitate this?

Thanks

share|improve this question
add comment

3 Answers 3

up vote 12 down vote accepted

A couple of steps are necessary in order to get Tridion to use a CSS preprocessor, but it certainly can be done:

  1. Install Sass on the Tridion server. Since Tridion runs on windows machines, you should install first Ruby, and then Sass. You need to be able to build Sass things from the command line.
  2. Make sure that .scss is a valid mimetype. Within the Tridion gui, goto Administration > Multimedia Types > Show Multimedia Types. Click New Multimedia Type and create one for scss. look at the "Cascading style sheet" for inspiration on how to fill in the fields.
  3. Add Sass to the default multimedia schema. Find your default multimedia schema, open it up, and make sure that Sass is added to "allowed multimedia types".

At this point you can do the following:

  • upload .scss files into tridion as binaries
  • add them to a page under a component template (commonly the "code component template)

You could even publish the page, but it won't do you any good... yet!

You still need to build the Sass, for this is the more difficult and fourth step:

  1. Create a TBB that "processes" your preprocessed CSS. You'll need a .NET assembly to do this. That assembly should grab the .scss files via a webdav URL, execute the build command, and then the value returned should be the built page - which is now CSS.
share|improve this answer
add comment

There's probably a number of ways to do this, here is roughly how I would look at implementing:

  1. create a multimedia type in the CMS to support the .scss file extension

  2. associate that mm extension to an existing or new multimedia schema (i'd probably do a 'sass' specific schema so it can have a 1-1 relation ship with a component template)

  3. Associate your 'sass schema' to a CMS component template, e.g 'SASS to CSS Processor'.

  4. Your component template is build using .net, so it's a case here of extracting the content from your uploaded .scss file (really simply using the TOM.NET api), the using one of the many SASS .net libraries to do the compilation to CSS (for example: http://libsassnet.codeplex.com/), you can then use the TOM.NET api to publish the file as needed

let me know if you need any more detail.

share|improve this answer
    
Thanks John. Your additional details about compiling the SASS in .net are very useful. –  Luke Jan 30 at 10:47
add comment

This is using LESS rather than SASS, but a similar process to follow:

http://www.building-blocks.com/thinking/adding-less-support-to-sdl-tridion/

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.