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

webpack使用art-template-loader如何传递数据 #41

Open
imdoge opened this issue Dec 28, 2018 · 4 comments
Open

webpack使用art-template-loader如何传递数据 #41

imdoge opened this issue Dec 28, 2018 · 4 comments

Comments

@imdoge
Copy link

imdoge commented Dec 28, 2018

对比服务端的

app.engine("art", require("express-art-template"));
app.set("view engine", "art");

然后

res.render("index", data);

客户端也可以

template.render(source, data, options);

请问webpack的打包如何传递数据呢?

{
  test: /\.art$/,
  loader: "art-template-loader"
}
@aui
Copy link
Collaborator

aui commented Dec 29, 2018

template.render(source, data, options);

@imdoge
Copy link
Author

imdoge commented Dec 29, 2018

这个是客户端吧,我是想在webpack打包的时候就传数据进去,把模板打包成对应的页面,这样是可以的吗

@imdoge
Copy link
Author

imdoge commented Dec 29, 2018

例如index.art
<div>{{ title }}</div>
有没有类似这样的写法

{
  test: /\.art$/,
  loader: "art-template-loader",
  options: {
    data: { title: "title1" }
  }
}

然后打包成 <div>title1</div>

@imdoge
Copy link
Author

imdoge commented Dec 29, 2018

因为是想打包成静态页面,不用后台来res.render,也不打算ajax请求数据然后客户端template.render

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

2 participants