koajs / ejs

a koa view render middleware, support all feature of ejs
MIT License
248 stars 56 forks source link

why the response like this? #35

Closed DarkPage closed 7 years ago

DarkPage commented 7 years ago

I use koa2 and koa-ejs to make a react ssr demo koa code:

const markup = renderToString(
    <Provider store={store()} >
        <RouterContext { ...props } />
    </Provider>
);
await ctx.render('index', { markup });

chrome devtool look like this:

<html>
<head>
    <title>koa2 webpack2 react ssr</title>
</head>
<body>
    <div id="root">&lt;div data-reactroot=&#34;&#34; data-reactid=&#34;1&#34; data-react-checksum=&#34;-1292022691&#34;&gt;&lt;h4 data-reactid=&#34;2&#34;&gt;This is React App Component&lt;/h4&gt;&lt;a href=&#34;/a&#34; data-reactid=&#34;3&#34;&gt;A&lt;/a&gt;&lt;a href=&#34;/b&#34; data-reactid=&#34;4&#34;&gt;B&lt;/a&gt;&lt;a href=&#34;/c&#34; data-reactid=&#34;5&#34;&gt;C&lt;/a&gt;&lt;div data-reactid=&#34;6&#34;&gt;This is B&lt;/div&gt;&lt;/div&gt;</div>
    <script src="./bundle.js"></script>
</body>
</html>

why?

DarkPage commented 7 years ago

It's my mistake, i change my template <%= obj &> to <%- obj &> T_T