Core

/views/components/fieldview/JSON.html (574 B)

 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{% import (
"{{{ .Package }}}/app/controller/cutil"
"{{{ .Package }}}/app/util"
) %}

{% func JSON(v any) %}{% stripspace %}
{% code
b, ok := v.([]byte)
if ok {
_ = util.FromJSON(b, &v)
}
%}
{% code out, err := cutil.FormatJSON(v) %}
{% if err == nil %}
{%s= out %}
{% else %}
{%s err.Error() %}
{% endif %}
{% endstripspace %}{% endfunc %}

{% func JSONInline(v any) %}{% stripspace %}
{% code
b, ok := v.([]byte)
if ok {
_ = util.FromJSON(b, &v)
}
%}
{%s util.ToJSON(v) %}
{% endstripspace %}{% endfunc %}