[英]Unable to Render nested tags in server side Riot.JS
I'm trying to use Riotjs in server side I have three files testcmp.js
, test1.tag
, test2.tag
我正在尝试在服务器端使用Riotjs我有三个文件
testcmp.js
, test1.tag
和test2.tag
testcmp.js
var riot = require('riot');
var test1 = require('../src/components/test/test1.tag')
var test2 = require('../src/components/test/test2.tag')
console.log(riot.render('test2',{yo2:"hello"}))
test1.tag
<test1><div>I'm in test1 {opts.yo}</div></test1>
test2.tag
<test2>
<test1 yo="sujeet"></test1>
hello, I'm in test2 {yo2}
</test2>
and when I run the testcmp.js file, I get the following error message 当我运行testcmp.js文件时,出现以下错误消息
/home/sujeet/Desktop/labz/authblue-ui-ssr-spike/src/components/test/test2.tag:2
var riot = require('riot')
^^^^^^^^^^^^^^^
ReferenceError: Invalid left-hand side in assignment
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at loadAndCompile (/home/sujeet/Desktop/labz/authblue-ui-ssr-spike/node_modules/riot/lib/server/index.js:33:11)
at Object.require.extensions..tag (/home/sujeet/Desktop/labz/authblue-ui-ssr-spike/node_modules/riot/lib/server/index.js:55:3)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
npm ERR! Linux 4.13.0-32-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "testcmp"
npm ERR! node v6.11.4
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! authblue-ui-ssr-spike@1.0.0 testcmp: `node scripts/testcmp`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the authblue-ui-ssr-spike@1.0.0 testcmp script 'node scripts/testcmp'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the authblue-ui-ssr-spike package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node scripts/testcmp
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs authblue-ui-ssr-spike
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls authblue-ui-ssr-spike
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/sujeet/Desktop/labz/authblue-ui-ssr-spike/npm-debug.log
Enclosing the text inside the test2.tag file helped me fix the issue. 将文本包含在test2.tag文件中有助于解决此问题。
Basically, something like this 基本上是这样的
<test2>
<test1 yo="sujeet"></test1>
<span>hello, I'm in test2 {yo2} </span>
</test2>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.