简体   繁体   English

html标签中百分号表达式的含义是什么?

[英]what is the meaning of percent sign expressions in html tag?

I found some strange sign <%%> in angular2-seed, what is the <% %> used for? 我在angular2-seed中发现了一些奇怪的符号<%%>,<%%>用于什么?

https://github.com/AngularClass/angular2-webpack-starter/blob/master/src/index.html https://github.com/AngularClass/angular2-webpack-starter/blob/master/src/index.html

 <!DOCTYPE html> <html lang=""> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title><%= htmlWebpackPlugin.options.title %></title> <meta name="description" content="<%= htmlWebpackPlugin.options.title %>"> <% if (webpackConfig.htmlElements.headTags) { %> <!-- Configured Head Tags --> <%= webpackConfig.htmlElements.headTags %> <% } %> <!-- base url --> <base href="<%= htmlWebpackPlugin.options.metadata.baseUrl %>"> </head> <body> <app> Loading... </app> ..... <% if (htmlWebpackPlugin.options.metadata.isDevServer && htmlWebpackPlugin.options.metadata.HMR !== true) { %> <!-- Webpack Dev Server reload --> <script src="/webpack-dev-server.js"></script> <% } %> </body> </html> 

That's usually processed by code in the HTTP server and replaced by dynamically generated strings before the complete page is sent as response to a browser request. 这通常由HTTP服务器中的代码处理,并在完整页面作为对浏览器请求的响应发送之前由动态生成的字符串替换。

See for example 例如,参见

Actually it's HTML Webpack Plugin https://github.com/ampedandwired/html-webpack-plugin 实际上它是HTML Webpack插件https://github.com/ampedandwired/html-webpack-plugin

If you search for HtmlWebpackPlugin against the project, you will get the following js, and it points to the template file, and the template engine helps decode it to html file. 如果您针对项目搜索HtmlWebpackPlugin,您将获得以下js,它指向模板文件,模板引擎帮助将其解码为html文件。

   /*
   * Plugin: HtmlWebpackPlugin
   * Description: Simplifies creation of HTML files to serve your webpack bundles.
   * This is especially useful for webpack bundles that include a hash in the filename
   * which changes every compilation.
   *
   * See: https://github.com/ampedandwired/html-webpack-plugin
   */
  new HtmlWebpackPlugin({
    template: 'src/index.html',
    title: METADATA.title,
    chunksSortMode: 'dependency',
    metadata: METADATA,
    inject: 'head'
  }),

I think this is what you were trying to figure out. 我想这就是你想弄清楚的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM