Comments (5)
This is code also doesn't work https://gist.github.com/gr1feel/5418016
I suppose what problem in parentheses.
from vash.
I'm not sure I follow, those render just fine for me:
$ echo '<a onclick="alert('@model.text1')">click me!</a> ' | ./node_modules/vash/bin/vash --json '{"debug": false}' --render '{ "text1": "hello" }'
<a onclick="alert(hello)">click me!</a>
drewp@SpottedRadioFreeAir /tmp/vash-test$ node
> var vash = require('vash');
undefined
> var tpl = vash.compile("<a onclick=\"alert('@model.text1')\">click me!</a>")
undefined
> tpl({ text1: "hello" })
'<a onclick="alert(\'hello\')">click me!</a>'
Could you provide more details as to what "fail" means in your case?
from vash.
Any other details you can provide?
from vash.
Hi,
Sorry for delay. Check this example (pages /test1 and /test2).
https://docs.google.com/file/d/0B0E2riyj_WiwVDBNMnpvTndBaFU/view
from vash.
Ok, thanks for the examples, they really help.
The issue is that a <br />
tells Vash to enter and immediately exit markup mode and return to the previous mode, which is this case is a code block. Thus Text1:
and Text2:
are being interpreted as code instead of markup. Vash requires that any actual content be wrapped in either html tags (or the fake <text>
tag) or an @:
for a single line.
There is another issue too in the same vein. The parentheses in (@model.text2)
are being interpreted as code. When compiled, it looks like this:
(__vbuffer.push(html.escape(model.text2).toHtmlString());)
A semicolon is not valid JS within the grouping parentheses, so this is actually not even compiling. The error reporting is giving you a false sense of where the error is happening because it's not actually at runtime, but rather at compile time. This is just bad reporting that I've been meaning to fix, and have opened an issue to keep track of it (#22).
Your immediate solution:
@html.block('content', function(model){
@* Remember that <text> tags are not rendered! *@
<text>
<br/>Text1: @model.text1
<br/>Text2: @model.text2
<br/>@model.child.xxx
<span>hi</span> (@model.text2)
</text>
})
There are others, like using @:
on each line (pretty gross, just an example):
@html.block('content', function(model){
@:<br/>Text1: @model.text1
@:<br/>Text2: @model.text2
<br/>@model.child.xxx
@:<span>hi</span> (@model.text2)
})
from vash.
Related Issues (20)
- Feature Request: Add support for render method HOT 5
- How to make multiple includes for the same component work? HOT 2
- <a> is not considered a void tag, should it?
- ..
- vash block error with koa HOT 6
- Vash HOT 2
- @foreach razor syntax HOT 3
- Conditions inside templates HOT 1
- <a href="@item.html">... HOT 3
- Missing output when using if/else if/else followed by another if HOT 3
- Use syntax highlighting in README.md HOT 1
- Output for blocks with the commandline tool or compile API HOT 2
- [question] How to use vash.helpers.include HOT 1
- Is this library no longer developing? HOT 2
- UnclosedNodeError: Found unclosed VashMarkup HOT 2
- Add Support for Tag Helpers
- Add support for compile file
- Trying to get in touch regarding a security issue HOT 2
- Add TypeScript definitions
- Error running the CodePen playground
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 vash.