private static void RegisterFilters(ILavaEngine engine) { // Register the common Rock.Lava filters first, then overwrite with the web-specific filters. if (engine.GetType() == typeof(RockLiquidEngine)) { engine.RegisterFilters(typeof(global::Rock.Lava.Filters.TemplateFilters)); engine.RegisterFilters(typeof(Rock.Lava.RockFilters)); } else { engine.RegisterFilters(typeof(global::Rock.Lava.Filters.TemplateFilters)); engine.RegisterFilters(typeof(Rock.Lava.LavaFilters)); } }
private static void RegisterBlocks(ILavaEngine engine) { // Get all blocks and call OnStartup methods if (engine.GetType() == typeof(RockLiquidEngine)) { // Find all tag elements that implement IRockStartup. var elementTypes = Rock.Reflection.FindTypes(typeof(DotLiquid.Block)).Select(a => a.Value).ToList(); foreach (var elementType in elementTypes) { var instance = Activator.CreateInstance(elementType) as IRockStartup; if (instance == null) { continue; } try { // RockLiquid blocks register themselves with the DotLiquid framework during their startup process. instance.OnStartup(); } catch (Exception ex) { var lavaException = new Exception(string.Format("Lava component initialization failure. Startup failed for Lava Tag \"{0}\".", elementType.FullName), ex); ExceptionLogService.LogException(lavaException, null); } } } else { try { // Get Lava block components, except shortcodes which are registered separately. var elementTypes = Rock.Reflection.FindTypes(typeof(ILavaBlock)).Select(a => a.Value).ToList(); elementTypes = elementTypes.Where(x => !(typeof(ILavaShortcode).IsAssignableFrom(x))).ToList(); foreach (var elementType in elementTypes) { var instance = Activator.CreateInstance(elementType) as ILavaBlock; var name = instance.SourceElementName; if (string.IsNullOrWhiteSpace(name)) { name = elementType.Name; } engine.RegisterBlock(name, (shortcodeName) => { var shortcode = Activator.CreateInstance(elementType) as ILavaBlock; return(shortcode); }); try { instance.OnStartup(engine); } catch (Exception ex) { var lavaException = new Exception(string.Format("Lava component initialization failure. Startup failed for Lava Block \"{0}\".", elementType.FullName), ex); ExceptionLogService.LogException(lavaException, null); } } } catch (Exception ex) { ExceptionLogService.LogException(ex, null); } } }