Comments (8)
Hi,
I changed this is for security reasons. Output is now always quoted as mithril also does.
you can avoid the quoting by using
return m('SCRIPT', m.trust('var who = ' + JSON.stringify(ctrl.js));
Didn't test if this works for JSON. May you can and confirm that it's working.
from mithril-node-render.
Yep, confirmed working, cheers! 👍
from mithril-node-render.
Ah, wait, no, I was still using 0.1.5.
It's still doing the quotes, even though it's m.trust - it seems as though it always applies the escapeHtml no matter what...
from mithril-node-render.
Stange
I'll fix that tomorrow. Fell free to open a PR if you want
from mithril-node-render.
I've created a mithril demo here:
http://codepen.io/jsguy/pen/azGmbw?editors=101
I'm not sure how to best solve this - do we need to override m.trust, so that we know the call is from there?
from mithril-node-render.
Also, here is a runnable, with the same view to show the issue in node:
http://web-b7843201-9634-4b57-b4ae-2203d5cc5bbd.runnable.com
Hmmm... if that doesn't work, (runnable is sometimes a little "moody"), the code is:
var http = require('http'),
m = require('mithril'),
render = require('mithril-node-render');
http.createServer(function (req, res) {
var result = "", obj = {"hello": "world"};
result = render(m("CODE", "var who = " + JSON.stringify(obj)));
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end(result);
}).listen(80);
console.log('Server listening on port 80');
Output:
<CODE>var who = {"hello":"world"}</CODE>
from mithril-node-render.
Just released 0.2.2
I now only escape quotes for attributes. Hope that solves the issue.
from mithril-node-render.
Works for me, thanks! 👍
from mithril-node-render.
Related Issues (20)
- innerHTML does not render HOT 3
- mithril v 1.0 compatible? HOT 1
- Still depends on [email protected] HOT 1
- has an demo HOT 2
- Can you add a DEMO? HOT 1
- Your Gitter badge is currently failing to render correctly on your README.md
- Add support to render sync HOT 2
- Missing m.route.param on the server ... HOT 4
- rewrite everything in TypeScript HOT 3
- can't use es6 class component
- How can i use it with jsx ? HOT 3
- Move mithril to a peerDependency
- Make class component check better match how Mithril does it
- Switch from `co` to `async`/`await`
- Adapt docs to async/await
- Future-proofing HOT 5
- Mithril's `oninit` is synchronous
- PSA: I've added a bunch of default community health files org-wide HOT 2
- Error doc HOT 5
- why "onclick" can't work HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mithril-node-render.