Class AbstractSASSController

java.lang.Object
org.javalite.activeweb.HttpSupport
org.javalite.activeweb.AppController
org.javalite.activeweb.controllers.AbstractSASSController
All Implemented Interfaces:
RequestAccess

public abstract class AbstractSASSController extends AppController

Subclass will compile and serve CSS from SASS files. For more information on SASS, please see https://sass-lang.com/. Usually a developer would subclass this controller to trigger and compile in development environment, but the URI to CSS file would be ignored by the framework (configured in RouteConfig), so that a statically compiled version is served by a container or a web server.

This controller does not by itself compile SASS files. It shells out to a sass compiler, which needs to be installed.

The controller will only compile SASS files if there have been any changes since the last invocation. If there has been no changes, it immediately serves the cached version of CSS compiled previously.

Example usage:


 public class BootstrapController extends AbstractSASSController {
        protected File getSASSFile() {
            return new File("src/main/webapp/sass/bootstrap.sass");
        }
    }
 ...

   public class RouteConfig extends AbstractRouteConfig {
      public void init(AppContext appContext) {
           ignore("/bootstrap.css").exceptIn("development");
      }
 }
 
The line in the RouteConfig ensures that the URI /bootstrap.css is ignored by the framework in every environment except "development". This is why the controller is triggering in development environment only.
Author:
igor on 4/28/14
  • Constructor Details

    • AbstractSASSController

      public AbstractSASSController()
  • Method Details

    • index

      public void index()
    • getSASSFile

      protected abstract File getSASSFile()
      Subclass should return a file handle pointing to the main SASS file.
      Returns:
      file handle pointing to the main SASS file
    • getSASSArguments

      protected String[] getSASSArguments()
      Subclass should override this method if they want to provide custom list of arguments to SASS compiler.
      Returns:
      custom list of arguments for SASS compiler.