Handlebars implementation of magnolia renderer using jknack library.
See this README for documentation on the blosom reference generator maven plugin.
- com.github.jknack.handlebars.io.ClassPathTemplateLoader
- com.merkle.oss.magnolia.renderer.handlebars.utils.DateUtil
- com.merkle.oss.magnolia.renderer.handlebars.utils.LinkUtil
- com.merkle.oss.magnolia.renderer.handlebars.utils.LocaleProvider
- com.merkle.oss.magnolia.renderer.handlebars.helpers.PatternHelper$TemplateScriptLocator
<dependency>
<groupId>com.namics.oss.magnolia</groupId>
<artifactId>magnolia-handlebars-renderer</artifactId>
<version>${merkle.oss.handlebars-renderer.version}</version>
</dependency>
<dependency>
<name>magnolia-handlebars-renderer</name>
<version>${merkle.oss.handlebars-renderer.version}</version>
</dependency>
<dependency>
<groupId>com.namics.oss.magnolia</groupId>
<artifactId>magnolia-handlebars-renderer-blossom</artifactId>
<version>${merkle.oss.handlebars-renderer.version}</version>
</dependency>
<dependency>
<name>magnolia-handlebars-renderer-blossom</name>
<version>${merkle.oss.handlebars-renderer.version}</version>
</dependency>
See separate Helpers documentation.
Custom jknack value resolvers can be configured by implementing a custom ValueResolversProvider
<component>
<type>com.merkle.oss.magnolia.renderer.handlebars.renderer.HandlebarsRenderer$ValueResolversProvider</type>
<implementation>custom.valueResolverProvider</implementation>
</component>
For the blossom renderer components can be restricted for certain roles using the AvailableForRoles annotation:
@AvailableForRoles("superuser")
@ContentArea
@Template(
id = Script.ID,
title = "templates.components." + Script.NAME + ".title",
dialog = ScriptDialog.ID
)
@Controller
@TemplateDescription("templates.components." + Script.NAME + ".description")
public class Script extends BaseComponent {
...
}
Example to only allow SomeComponent to be added inside backgroundArea:
@ContentArea
@Template(
id = Background.ID,
title = "templates.components." + Background.NAME + ".title",
dialog = BackgroundDialog.ID
)
@Controller
@TemplateDescription("templates.components." + Background.NAME + ".description")
public class Background extends BaseComponent {
public static final String NAME = "Background";
public static final String ID = COMPONENT_PREFIX + NAME;
...
@Area(value = Background.BackgroundColorItemArea.NAME, title = "templates.areas." + Background.BackgroundColorItemArea.NAME + ".title")
@AvailableComponentClasses({BackgroundArea.class})
@Controller
public static class BackgroundColorItemArea extends BaseArea {
public static final String NAME = "BackgroundColorItemArea";
...
}
}
@BackgroundArea
public class BackgroundAreaComponentAvailabilityPredicate implements AreaAndComponentIdPredicate {
@Override
public boolean test(final AreaAndComponentId areaAndComponentId) {
return SomeComponent.ID.equals(areaAndComponentId.getComponentId());
}
}
import com.google.inject.multibindings.MapBinder;
import com.merkle.oss.magnolia.renderer.handlebars.blossom.component.availability.ComponentAvailabilityPredicateResolver.AreaAndComponentIdPredicate;
import info.magnolia.objectfactory.guice.AbstractGuiceComponentConfigurer;
public class CustomGuiceComponentConfigurer extends AbstractGuiceComponentConfigurer {
@Override
protected void configure() {
super.configure();
MapBinder.newMapBinder(binder(), String.class, AreaAndComponentIdPredicate.class)
.addBinding(Background.BackgroundColorItemArea.NAME).to(BackgroundAreaComponentAvailabilityPredicate.class);
}
}