/**
 *
 */
package ro.isdc.wro.extensions.processor.js;

import java.io.IOException;
import java.io.Reader;
import java.io.Writer;

import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;

import ro.isdc.wro.extensions.processor.support.ObjectPoolHelper;
import ro.isdc.wro.extensions.processor.support.handlebarsjs.HandlebarsJs;
import ro.isdc.wro.model.resource.Resource;
import ro.isdc.wro.model.resource.processor.ResourcePreProcessor;
import ro.isdc.wro.util.ObjectFactory;


/**
 * This {@link ResourcePreProcessor} compiles HandlebarsJS templates to javascript.
 *
 * @author heldeen
 */
public class HandlebarsJsProcessor
    implements ResourcePreProcessor {
  public static final String ALIAS = "HandlebarsJs";

  private final ObjectPoolHelper<HandlebarsJs> enginePool;

  public HandlebarsJsProcessor() {
    enginePool = new ObjectPoolHelper<HandlebarsJs>(new ObjectFactory<HandlebarsJs>() {

      @Override
      public HandlebarsJs create() {
        return new HandlebarsJs();
      }

    });
  }

  @Override
  public void process(final Resource resource, final Reader reader, final Writer writer)
      throws IOException {

    final String content = IOUtils.toString(reader);
    final HandlebarsJs handlebarsJs = enginePool.getObject();
    final String name = resource == null ? "" : FilenameUtils.getBaseName(resource.getUri());

    try {
      writer.write(handlebarsJs.compile(content, name));
    } finally {
      enginePool.returnObject(handlebarsJs);
      reader.close();
      writer.close();
    }
  }

  public void process(final Reader reader, final Writer writer)
      throws IOException {
    process(null, reader, writer);
  }

}

@@ -393,16 +393,121 @@
 source;%0A
+import ro.isdc.wro.model.resource.ResourceType;%0Aimport ro.isdc.wro.model.resource.SupportedResourceType;%0A
 import r
@@ -616,43 +616,9 @@
 %0A * 
-This %7B@link ResourcePreProcessor%7D c
+C
 ompi
@@ -683,17 +683,73 @@
 ldeen%0A *
-/
+ @since 1.4.7%0A */%0A@SupportedResourceType(ResourceType.JS)
 %0Apublic 
@@ -852,17 +852,17 @@
 LIAS = %22
-H
+h
 andlebar
@@ -1051,17 +1051,16 @@
 Js%3E() %7B%0A
-%0A
       @O
@@ -1147,17 +1147,16 @@
       %7D%0A
-%0A
     %7D);%0A
@@ -1160,16 +1160,47 @@
 );%0A  %7D%0A%0A
+  /**%0A   * %7B@inheritDoc%7D%0A   */%0A
   @Overr
@@ -1319,17 +1319,16 @@
 ption %7B%0A
-%0A
     fina
@@ -1712,16 +1712,48 @@
  %7D%0A  %7D%0A%0A
+%0A  /**%0A   * %7B@inheritDoc%7D%0A   */%0A
   public

update javadoc and add missing annotation