
package org.apache.shindig.gadgets.templates;

import com.google.inject.AbstractModule;
import com.google.inject.multibindings.Multibinder;

import org.apache.shindig.gadgets.templates.tags.FlashTagHandler;
import org.apache.shindig.gadgets.templates.tags.HtmlTagHandler;
import org.apache.shindig.gadgets.templates.tags.IfTagHandler;
import org.apache.shindig.gadgets.templates.tags.RenderTagHandler;
import org.apache.shindig.gadgets.templates.tags.RepeatTagHandler;
import org.apache.shindig.gadgets.templates.tags.TagHandler;
import org.apache.shindig.gadgets.templates.tags.VariableTagHandler;

/**
 * Guice Module to provide Template-specific classes
 */
public class TemplateModule extends AbstractModule {

  @Override
  protected void configure() {
    bind(TemplateProcessor.class).to(DefaultTemplateProcessor.class);
    bindTagHandlers();
  }

  /* No need to subclass. 
     You can add the same construct in your own modules to register your own tag handler.. */
  protected void bindTagHandlers() {
    Multibinder<TagHandler> tagBinder = Multibinder.newSetBinder(binder(), TagHandler.class);
    tagBinder.addBinding().to(HtmlTagHandler.class);
    tagBinder.addBinding().to(IfTagHandler.class);
    tagBinder.addBinding().to(RenderTagHandler.class);
    tagBinder.addBinding().to(RepeatTagHandler.class);
    tagBinder.addBinding().to(FlashTagHandler.class);
    tagBinder.addBinding().to(VariableTagHandler.class);
  }
}
