Script: Implement a proper type check
Use `printf "%T"` to get a string that indicates the type of the `resource` context item. Build a resource if its a string. Pass a minify argument through to the build_js template.
This commit is contained in:
parent
8ae8136b8a
commit
23f31c4c10
1 changed files with 11 additions and 4 deletions
|
@ -6,17 +6,24 @@ looked up and built.
|
||||||
|
|
||||||
@context {string|Resource} resource
|
@context {string|Resource} resource
|
||||||
The Resource
|
The Resource
|
||||||
@context {bool} isModule
|
@context {bool} minify
|
||||||
|
If true and the resource is a string, it will be minified as part of the build
|
||||||
|
step.
|
||||||
|
@context {bool} module
|
||||||
If true, add information to the script element indicating it should be loaded
|
If true, add information to the script element indicating it should be loaded
|
||||||
as a module
|
as a module
|
||||||
|
|
||||||
*/ -}}
|
*/ -}}
|
||||||
|
|
||||||
{{- $resource := .resource -}}
|
{{- $resource := .resource -}}
|
||||||
|
{{- $shouldMinify := .minify -}}
|
||||||
{{- $isModule := .module -}}
|
{{- $isModule := .module -}}
|
||||||
|
|
||||||
{{ if $resource.resource }}
|
{{ if eq (printf "%T" $resource) "string" }}
|
||||||
{{ $resource = partial "resource_builders/build_js.html" $resource }}
|
{{
|
||||||
|
$resource = partial "resource_builders/build_js.html"
|
||||||
|
(dict "resource" $resource "minify" $shouldMinify)
|
||||||
|
}}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ with $resource }}
|
{{ with $resource }}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue