Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've neerly implement this. lets add something in the ejs example in express. <a href="https://github.com/visionmedia/express" rel="nofollow">https://github.com/visionmedia/express</a></p> <p>modify index.js, first import vm and fs</p> <pre><code>var express = require('express'), fs = require('fs'), vm = require('vm'); </code></pre> <p>then, route all *.shtml (any extension as you will)</p> <pre><code>app.get('*.shtml', function(req, res){ var url = req._parsedUrl.pathname; url = url.substring(1, url.length - 6); //console.log(req); var jsPath = 'controllers/' + url + '.js'; //console.log('jsPath ' + jsPath); if(fs.existsSync(jsPath)){ var code = fs.readFileSync(jsPath); var context = vm.createContext({req : req, res : res, url : url, console : console}); vm.runInContext(code, context, jsPath); } else { res.render(url, req.query); } }); </code></pre> <p>now, test.</p> <p>node index.js, now we are in runtime.</p> <p>put a new file named test.html in views</p> <pre><code>test.html: &lt;% include header.html %&gt; &lt;h1&gt;Test&lt;/h1&gt; &lt;% include footer.html %&gt; </code></pre> <p>type <code>test.shtml?title=Test Page</code>, so this page turn to show. and query param <em>title</em> bind within header.html.</p> <p>well, but we can do less in the page, for the render is controled by the res.render(). if we want to do something before render, or direct output something but not html content, lets have a look.</p> <p>create a folder named controllers, then create a file named test.js.</p> <pre><code>test.js console.log('do something....'); res.render(url, req.query); </code></pre> <p>type <code>test.shtml?title=Test Page</code> again, you will see test.js output 'do someting....' on the console, and then it render the same-name page in your browser.</p> <p>all the controller js and html files are all dynamic~~~</p> <p>thus the theme mode is not very closely to Apache Tiles yet. :(</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload