Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

my server side-rendering code #1

Open
crongro opened this issue Sep 30, 2015 · 0 comments
Open

my server side-rendering code #1

crongro opened this issue Sep 30, 2015 · 0 comments

Comments

@crongro
Copy link

crongro commented Sep 30, 2015

I created server.js based on the ideas of your code.

var _ld       = require('lodash');
var jspm      = require('jspm');
var express   = require('express');
var fs        = require('fs');

var app       = express();
app.use(express.static('.'));

var sTemplateHTML = fs.readFileSync('app/html/index.html', 'utf8');
jspm.setPackagePath('.');

var server = app.listen(8090, function () {
    console.log('Server Listen http://localhost:%s', server.address().port);
});

app.get("/render", function(req, res) {
    jspm.import('app/js/pages/mainServer')
        .then(function(sRenderedHTML) {
                var _htData = {'mycontent' : sRenderedHTML.default}
                var sResultHTML = _ld.template(sTemplateHTML)(_htData);
                res.end(sResultHTML);
            }, function(err) {console.log("SeverRendering Error :", err)}
        );
});

thank you :-D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant