{"record":{"id":"4639a999392a8fd5","repo":"Meituan-Dianping/mpvue","slug":"templates-should-only-be-responsible-for-mapping-t","errorCode":null,"errorMessage":"Templates should only be responsible for mapping the state to the UI. Avoid placing tags with side-effects in your templates, such as <${tag}>, as they will not be parsed.","messagePattern":"Templates should only be responsible for mapping the state to the UI\\. Avoid placing tags with side-effects in your templates, such as <(.+?)>, as they will not be parsed\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/weex-template-compiler/build.js","lineNumber":1432,"sourceCode":"      if (isIE && ns === 'svg') {\n        attrs = guardIESVGBug(attrs);\n      }\n\n      var element = {\n        type: 1,\n        tag: tag,\n        attrsList: attrs,\n        attrsMap: makeAttrsMap(attrs),\n        parent: currentParent,\n        children: []\n      };\n      if (ns) {\n        element.ns = ns;\n      }\n\n      if (isForbiddenTag(element) && !isServerRendering()) {\n        element.forbidden = true;\n        process.env.NODE_ENV !== 'production' && warn(\n          'Templates should only be responsible for mapping the state to the ' +\n          'UI. Avoid placing tags with side-effects in your templates, such as ' +\n          \"<\" + tag + \">\" + ', as they will not be parsed.'\n        );\n      }\n\n      // apply pre-transforms\n      for (var i = 0; i < preTransforms.length; i++) {\n        preTransforms[i](element, options);\n      }\n\n      if (!inVPre) {\n        processPre(element);\n        if (element.pre) {\n          inVPre = true;\n        }\n      }\n      if (platformIsPreTag(element.tag)) {","sourceCodeStart":1414,"sourceCodeEnd":1450,"githubUrl":"https://github.com/Meituan-Dianping/mpvue/blob/6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b/packages/weex-template-compiler/build.js#L1414-L1450","documentation":"Tags with browser side-effects (e.g. <script>, <style>... per isForbiddenTag) are not allowed in templates because templates should only map state to UI. When the parser encounters such a tag outside server rendering, it marks element.forbidden = true so the tag is skipped, and warns in development.","triggerScenarios":"Compiling a template containing a forbidden tag (such as <script> or <style>) in a client-side (non-server-rendering) compilation, so isForbiddenTag(element) returns true and warn is configured.","commonSituations":"Inlining <script> tags in a component template to add tracking code, pasting full HTML pages (with head/script tags) into a component, or trying to load third-party widgets inside a Vue template.","solutions":["Remove the side-effect tag from the template","Load scripts programmatically (e.g. in mounted()) instead of via <script> in the template","Move styles to a proper style block or CSS file rather than a template <style> tag"],"exampleFix":"// before\n<template><div><script src=\"x.js\"></script></div></template>\n// after\n<template><div></div></template>\n<script>\nexport default { mounted() { /* inject script here */ } }\n</script>","handlingStrategy":"validation","validationCode":"const FORBIDDEN = ['style','script','iframe','video','audio','object','embed','form'];\nfunction hasForbiddenTags(template) {\n  return FORBIDDEN.filter(t => new RegExp(`<${t}[\\\\s>]`, 'i').test(template));\n}","typeGuard":"function isTemplateSafe(template) {\n  return typeof template === 'string' && hasForbiddenTags(template).length === 0;\n}","tryCatchPattern":null,"preventionTips":["Never inline <script> or <style> in component templates","Inject third-party scripts from mounted()/plugins instead","Lint templates with a rule that flags side-effect tags"],"tags":["template","security","side-effects","vue","weex"],"backgroundTag":"side-effect-tag-in-template","analyzedSha":"6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b","analyzedAt":"2026-09-02T05:17:40.946Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}