jvandemo / jvandemo/generator-angular2-library

bug: inline-resources/inlineTemplate escape

Open
#148 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
740
Forks
116
PR merge metrics
No merged PRs in 30d

Description

in html

``

Will be converted to

`template: "" // wrong`
`template: "" // correct`

in inline-resources.js

function inlineTemplate(content, urlResolver) {
return content.replace(/templateUrl:\s*'([^']+?\.html)'/g, function (m, templateUrl) {
const templateFile = urlResolver(templateUrl);
const templateContent = fs.readFileSync(templateFile, 'utf-8');
const shortenedTemplate = templateContent
.replace(/([\n\r]\s*)+/gm, ' ')

.replace(/\\/g, '\\\\') // does it should be added ?

.replace(/"/g, '\\"');
return `template: "${shortenedTemplate}"`;
});
}

my english is not good, I hope you can understand what I mean

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in inline-resources.js at inlineTemplate and compare the two shown template strings for an HTML pattern containing \d. Verify how the existing replacements handle backslashes and quotes; done means the generated template preserves the pattern as the correct escaped string shown in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, javascript
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.