You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can compile your tags also using the new registerPreprocessor and registerPostprocessor APIs for example:
import{compiler,registerPreprocessor,registerPostprocessor,}from'@riotjs/compiler'importpugfrom'pug'import*asbabelfrom'@babel/core'// process your tag template before it will be compiledregisterPreprocessor('template','pug',function(code,{ options }){const{ file }=optionsconsole.log('your file path is:',file)return{code: pug.render(code),// no sourcemap heremap: null,}})// your compiler output will pass from hereregisterPostprocessor(function(code,{ options }){const{ file }=optionsconsole.log('your file path is:',file)// notice that babel.transformSync returns {code, map}returnbabel.transformSync(code)})const{ code, map }=compile('<p>{hello}</p>',{// specify the template preprocessortemplate: 'pug',})
API
compile(string, options)
@returns { code, map } output that can be used by Riot.js
string: is your tag source code
options: the options should contain the file key identifying the source of the string to compile and
the template preprocessor to use as string
Note: specific preprocessors like the css or the javascript ones can be enabled simply specifying the type attribute
in the tag source code for example