use safeJS
This commit is contained in:
parent
1da4c591d2
commit
a83f339dc8
3 changed files with 31 additions and 21 deletions
|
@ -1,46 +1,56 @@
|
||||||
{{- /*
|
{{- /*
|
||||||
Renders a single item's required footer JS scripts.
|
Renders a single item's required footer JS scripts.
|
||||||
|
|
||||||
@params sc Site context.
|
@params sc Site context.
|
||||||
@params pc Page context.
|
@params pc Page context.
|
||||||
*/
|
*/
|
||||||
-}}
|
-}}
|
||||||
|
|
||||||
|
|
||||||
<!-- Validation -->
|
<!-- Validation -->
|
||||||
|
|
||||||
{{- if ( not ( isset . "sc" ) ) -}}
|
{{- if ( not ( isset . "sc" ) ) -}}
|
||||||
{{- errorf "No site context passed" -}}
|
{{- errorf "No site context passed" -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{- if ( not ( isset . "pc" ) ) -}}
|
{{- if ( not ( isset . "pc" ) ) -}}
|
||||||
{{- errorf "No page context passed" -}}
|
{{- errorf "No page context passed" -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{- if ( and ( .pc.HasShortcode "chart" ) ( not ( .pc.Page.Resources.GetMatch "charts-init" ) ) ) -}}
|
{{- if ( and ( .pc.HasShortcode "chart" ) ( not ( .pc.Page.Resources.GetMatch "charts-init" ) ) ) -}}
|
||||||
{{- errorf "No 'chart-init' page resource defined (%q)" .pc.Page.File.Path -}}
|
{{- errorf "No 'chart-init' page resource defined (%q)" .pc.Page.File.Path -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
|
|
||||||
<!-- Rendering -->
|
<!-- Rendering -->
|
||||||
|
|
||||||
{{ if .pc.Params.locations }}
|
{{ if .pc.Params.locations }}
|
||||||
{{-
|
<script>
|
||||||
partialCached
|
{{-
|
||||||
"scripts/show_post_locations_on_map.html"
|
(
|
||||||
( dict
|
partialCached
|
||||||
"pc" .pc
|
"scripts/show_post_locations_on_map.js"
|
||||||
"locations_data" .sc.Site.Data.locations
|
( dict
|
||||||
"locations" .pc.Params.locations
|
"pc" .pc
|
||||||
)
|
"locations_data" .sc.Site.Data.locations
|
||||||
.pc.Params.locations
|
"locations" .pc.Params.locations
|
||||||
|
)
|
||||||
|
.pc.Params.locations
|
||||||
|
) | safeJS
|
||||||
-}}
|
-}}
|
||||||
|
</script>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ if .pc.HasShortcode "chart" }}
|
{{ if .pc.HasShortcode "chart" }}
|
||||||
{{- $configJs := ( .pc.Page.Resources.GetMatch "charts-init" | fingerprint ) -}}
|
{{- $configJs := ( .pc.Page.Resources.GetMatch "charts-init" | fingerprint ) -}}
|
||||||
|
<script>
|
||||||
{{-
|
{{-
|
||||||
partialCached
|
(
|
||||||
"scripts/charts.html"
|
partialCached
|
||||||
$configJs
|
"scripts/charts.js"
|
||||||
$configJs
|
$configJs
|
||||||
|
$configJs
|
||||||
|
) | safeJS
|
||||||
-}}
|
-}}
|
||||||
|
</script>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue