embedJsInHtmlSource static method
String
embedJsInHtmlSource(
- String source,
- Set<
String> jsContents, { - EmbedPosition position = EmbedPosition.aboveBodyCloseTag,
Embeds js in the HTML source at the specified position This is just a helper function for the generic embedInHtmlSource function
Implementation
static String embedJsInHtmlSource(
String source,
Set<String> jsContents, {
EmbedPosition position = EmbedPosition.aboveBodyCloseTag,
}) {
const newLine = '\n';
const scriptOpenTag = '<script>';
const scriptCloseTag = '</script>';
final jsContent =
jsContents.reduce((prev, elem) => prev + newLine * 2 + elem);
final whatToEmbed = newLine +
scriptOpenTag +
newLine +
jsContent +
newLine +
scriptCloseTag +
newLine;
return embedInHtmlSource(
source: source,
whatToEmbed: whatToEmbed,
position: position,
);
}