ro.isdc.wro.extensions.processor.js
Class JsTemplateCompilerProcessor

java.lang.Object
  extended by ro.isdc.wro.extensions.processor.js.JsTemplateCompilerProcessor
All Implemented Interfaces:
ResourcePreProcessor
Direct Known Subclasses:
DustJsProcessor, EmberJsProcessor, HandlebarsJsProcessor, HoganJsProcessor

public abstract class JsTemplateCompilerProcessor
extends Object
implements ResourcePreProcessor

A base class for template processors like: dustJS or hoganJS.

Since:
1.4.7
Author:
Eivind Barstad Waaler

Constructor Summary
JsTemplateCompilerProcessor()
           
 
Method Summary
protected abstract  AbstractJsTemplateCompiler createCompiler()
           
protected  String getArgument(Resource resource)
           
 void process(Resource resource, Reader reader, Writer writer)
          Process a content supplied by a reader and perform some sort of processing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JsTemplateCompilerProcessor

public JsTemplateCompilerProcessor()
Method Detail

process

public void process(Resource resource,
                    Reader reader,
                    Writer writer)
             throws IOException
Process a content supplied by a reader and perform some sort of processing. It is important to know that you should use reader for processing instead of trying to access the resource original content using Resource, because this way you can ignore the other preProcessors from the chain.
It is not require to explicitly handle exception. When the processing fails, the following can happen:
It is not required to close the reader and writers, because these will be closed for you.

Specified by:
process in interface ResourcePreProcessor
Parameters:
resource - the original resource as it found in the model.
reader - Reader used to read processed resource content.
writer - Writer where used to write processed results.
Throws:
IOException - when an exception occurs. The future version will change the exception type to Exception, because any exception may occur during processing. The processing failure will be handled based on value of WroConfiguration.isIgnoreFailingProcessor() configuration flag.

getArgument

protected String getArgument(Resource resource)
Parameters:
resource - Resource being processed by compiler.
Returns:
arguments consumed by the js compile script.

createCompiler

protected abstract AbstractJsTemplateCompiler createCompiler()
Returns:
the AbstractJsTemplateCompiler responsible for compiling the template.


Copyright © 2008-2013. All Rights Reserved.