Task Detail

  • Activity on Fri May 25 2018 12:59:31 GMT+0000 (UTC) 1. Everytime the server get a request to serve a marko page, it then hands it over to marko to translate into html and then render to browser. 2. First, I need to have my Fastify server.js to serve Marko as its view option. /** use marko view for html content */ //require('marko/node-require').install(); //tells marko to not output .js files require('marko/compiler').defaultOptions.writeToDisk = false; fastify.register(view, { engine: { marko: require('marko') }, includeViewExtension: true }) log.trace('finished marko initialization') /** end of use marko for html content */ 3. To understand more about marko, visit npm marko 4. There are might be problem for marko to run as first, but search for the error on Google if any. 5. Created a view folder and a home folder inside view folder. 6. Created a .marko file with simple html content in there (<h1>hello Marko</h1>). 7. At this point because of modularity style, the view/home/index.marko will not effect anything when I start my application. 8. In plugins/home/index.js, create route and logic to serve the view/home/index.marko fastify.get('/', async (req, reply) => { reply.view('/view/home/index', {text:'text'}); }) 9. IMPORTANT: keep modularity style in mind - if we don't like a view later, we can just delete the view and its plugin, and this will not effect the application at all.

    10/26/2024 14:30:32