Package com.google.sitebricks

Examples of com.google.sitebricks.Template


  @Test
  public final void readHtmlWidgetWithChildren() {

    Renderable widget = compiler()
        .compile(TestBackingType.class, new Template("<!doctype html><html><body><div class='${clazz}'>hello @ShowIf(false)<a href='/hi/${id}'>hideme</a></div></body></html>"));

    assert null != widget : " null ";
    final Respond mockRespond = RespondersForTesting.newRespond();
    widget.render(new TestBackingType("Dhanji", "content", 12), mockRespond);
    final String s = mockRespond.toString();
View Full Code Here


  @Test
  public final void readEmbedWidgetAndStoreAsPage() {

    Renderable widget = compiler()
        .compile(TestBackingType.class, new Template("<xml><div class='content'>hello @MyFave(should=false)<a href='/hi/${id}'>hideme</a></div></xml>"));

    assert null != widget : " null ";

    //tell pagebook to track this as an embedded widget
    pageBook.embedAs(MyEmbeddedPage.class, MyEmbeddedPage.MY_FAVE_ANNOTATION)
View Full Code Here

  @Test
  public final void readEmbedWidgetOnly() {

    Renderable widget = compiler()
        .compile(TestBackingType.class, new Template("<html><div class='content'>hello @MyFave(should=false)<a href='/hi/${id}'>hideme</a></div></html>"));

    assert null != widget : " null ";

    //tell pagebook to track this as an embedded widget
    pageBook.embedAs(MyEmbeddedPage.class, MyEmbeddedPage.MY_FAVE_ANNOTATION)
View Full Code Here

    assert "asodkoas".equals(Dom.extractKeyAndContent("@Thing(asodkoas)  ")[1]) : "Extraction wrong: ";
    assert "asodkoas".equals(Dom.extractKeyAndContent("@Thing(asodkoas)  kko")[1]) : "Extraction wrong: ";
  }

  private Template template(String text) {
    return new Template("template.fml", text, new MemoryTemplateSource());
  }
View Full Code Here

    page.apply(widget);
  }

  @Override
  public Renderable compile(Class<?> templateClass) {
    final Template template = loader.load(templateClass);

    Renderable widget;

    //is this an HTML, XML, or a flat-file template?
    switch(template.getKind()) {
      default:
      case HTML:
        widget = compileHtml(templateClass, template.getText());
        break;
      case XML:
        widget = compileXml(templateClass, template.getText());
        break;
      case FLAT:
        widget = compileFlat(templateClass, template.getText());
        break;
      case MVEL:
        widget = compileMvel(templateClass, template.getText());
        break;
      case FREEMARKER:
        widget = compileFreemarker(templateClass, template.getText());
        break;
    }
    return widget;
  }
View Full Code Here

TOP

Related Classes of com.google.sitebricks.Template

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.