import Templating from "../templating" ; import TemplateEngine from "../models/templateEngine" ; import Api from "../api" ; import Plugins from "../plugins" ; import defaultBlocks from "../constants/defaultBlocks" ; import defaultFilters from "../constants/defaultFilters" ; param { Output } output return { TemplateEngine } function createTemplateEngine ( output ) { const plugins = output . getPlugins ( ) ; const book = output . getBook ( ) ; const rootFolder = book . getContentRoot ( ) ; const logger = book . getLogger ( ) ; let filters = Plugins . listFilters ( plugins ) ; let blocks = Plugins . listBlocks ( plugins ) ; blocks = defaultBlocks . merge ( blocks ) ; filters = defaultFilters . merge ( filters ) ; const transformFn = Templating . replaceShortcuts . bind ( null , blocks ) ; const loader = new Templating . ConrefsLoader ( rootFolder , transformFn , logger ) ; const context = Api . encodeGlobal ( output ) ; return new TemplateEngine ( { filters : filters , blocks : blocks , loader : loader , context : context , } ) ; } export default createTemplateEngine ;