def get_compilers(self): """Finds any {% apply assetman.foo %} blocks in the given compiled Template object and yields insantiated AssetCompiler instances for each block. """ # Map from template-side assetman manager calls to the corresponding # compiler classes for asset_block in self.__iter_child_nodes(self.template.file, self.__is_assetman_block): include_expr = include_expr_matcher(asset_block.method).group(1) assert include_expr in base.compiler_map, 'No compiler for %s' % asset_block.method compiler_cls = base.compiler_map[include_expr] yield compiler_cls(self.__extract_text(asset_block), self.template_path, settings=self.settings, src_path=self.path)
def __is_assetman_block(self, node): """Returns a bool indicating whether the given template node is an assetman {% apply %} block. """ return isinstance(node, tornado.template._ApplyBlock) \ and include_expr_matcher(node.method)