We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
querySelectorAll
<script>
Given an Angular HTML template being something like the following:
<div class="card"> <div ng-include="'app/templates/_something.html'"></div> <div ng-include="'my_template.html'"></div> <script type="text/ng-template id="my_template.html"> <div class="card"> <div class="card-body"> <div ng-include="'app/templates/_filters.html'"></div> </div> </div> </script> </div>
When I try to match all the ng-include from that HTML code using the following JavaScript code:
ng-include
const { parse } = require('node-html-parser'); const angularHtmlTemplate = `<div class="card"> <div ng-include="'app/templates/_something.html'"></div> <div ng-include="'my_template.html'"></div> <script type="text/ng-template id="my_template.html"> <div class="card"> <div class="card-body"> <div ng-include="'app/templates/_filters.html'"></div> </div> </div> </script> </div>` const parsedContent = parse(angularHtmlTemplate) const ngIncludes = parsedContent.querySelectorAll("*[ng-include]") console.log('ngIncludes are:') ngIncludes.forEach((ngInclude) => console.log(ngInclude.getAttribute('ng-include')))
This show me only the 2 first ng-include, the one included within the script template is ignored:
ngIncludes are: 'app/templates/_something.html' 'my_template.html'
While if I change the <script> tag as <div> tag, querySelectorAll returns 3 items as expected.
<div>
The text was updated successfully, but these errors were encountered:
try this:
const parsedContent = parse(angularHtmlTemplate, { blockTextElements: {} });
Sorry, something went wrong.
No branches or pull requests
Given an Angular HTML template being something like the following:
When I try to match all the
ng-include
from that HTML code using the following JavaScript code:This show me only the 2 first
ng-include
, the one included within the script template is ignored:While if I change the
<script>
tag as<div>
tag,querySelectorAll
returns 3 items as expected.The text was updated successfully, but these errors were encountered: