@gov-cy/govcy-frontend-renderer 1.17.0 → 1.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -6691,32 +6691,41 @@ context.setVariable("textType", t_3);
|
|
|
6691
6691
|
if(frame.topLevel) {
|
|
6692
6692
|
context.addExport("textType", t_3);
|
|
6693
6693
|
}
|
|
6694
|
+
var t_4;
|
|
6695
|
+
t_4 = env.getFilter("default").call(context, runtime.memberLookup((l_params),"showNewLine"),false);
|
|
6696
|
+
frame.set("showNewLine", t_4, true);
|
|
6697
|
+
if(frame.topLevel) {
|
|
6698
|
+
context.setVariable("showNewLine", t_4);
|
|
6699
|
+
}
|
|
6700
|
+
if(frame.topLevel) {
|
|
6701
|
+
context.addExport("showNewLine", t_4);
|
|
6702
|
+
}
|
|
6694
6703
|
if(runtime.memberLookup((l_params),"text")) {
|
|
6695
|
-
env.getTemplate("utilities/govcyUtilities.njk", false, "elements/textElement.njk", false, function(t_5
|
|
6696
|
-
if(t_5) { cb(t_5); return; }
|
|
6697
|
-
t_4.getExported(function(t_6,t_4) {
|
|
6704
|
+
env.getTemplate("utilities/govcyUtilities.njk", false, "elements/textElement.njk", false, function(t_6,t_5) {
|
|
6698
6705
|
if(t_6) { cb(t_6); return; }
|
|
6699
|
-
|
|
6700
|
-
|
|
6706
|
+
t_5.getExported(function(t_7,t_5) {
|
|
6707
|
+
if(t_7) { cb(t_7); return; }
|
|
6708
|
+
if(Object.prototype.hasOwnProperty.call(t_5, "govcyLocalizeContent")) {
|
|
6709
|
+
var t_8 = t_5.govcyLocalizeContent;
|
|
6701
6710
|
} else {
|
|
6702
6711
|
cb(new Error("cannot import 'govcyLocalizeContent'")); return;
|
|
6703
6712
|
}
|
|
6704
|
-
context.setVariable("govcyLocalizeContent",
|
|
6705
|
-
if(Object.prototype.hasOwnProperty.call(
|
|
6706
|
-
var
|
|
6713
|
+
context.setVariable("govcyLocalizeContent", t_8);
|
|
6714
|
+
if(Object.prototype.hasOwnProperty.call(t_5, "govcyLangAttribute")) {
|
|
6715
|
+
var t_9 = t_5.govcyLangAttribute;
|
|
6707
6716
|
} else {
|
|
6708
6717
|
cb(new Error("cannot import 'govcyLangAttribute'")); return;
|
|
6709
6718
|
}
|
|
6710
|
-
context.setVariable("govcyLangAttribute",
|
|
6719
|
+
context.setVariable("govcyLangAttribute", t_9);
|
|
6711
6720
|
if(runtime.contextOrFrameLookup(context, frame, "textType") == "p" || runtime.contextOrFrameLookup(context, frame, "textType") == "h1" || runtime.contextOrFrameLookup(context, frame, "textType") == "h2" || runtime.contextOrFrameLookup(context, frame, "textType") == "h3" || runtime.contextOrFrameLookup(context, frame, "textType") == "h4" || runtime.contextOrFrameLookup(context, frame, "textType") == "span") {
|
|
6712
|
-
var
|
|
6713
|
-
|
|
6714
|
-
frame.set("textTag",
|
|
6721
|
+
var t_10;
|
|
6722
|
+
t_10 = runtime.contextOrFrameLookup(context, frame, "textType");
|
|
6723
|
+
frame.set("textTag", t_10, true);
|
|
6715
6724
|
if(frame.topLevel) {
|
|
6716
|
-
context.setVariable("textTag",
|
|
6725
|
+
context.setVariable("textTag", t_10);
|
|
6717
6726
|
}
|
|
6718
6727
|
if(frame.topLevel) {
|
|
6719
|
-
context.addExport("textTag",
|
|
6728
|
+
context.addExport("textTag", t_10);
|
|
6720
6729
|
}
|
|
6721
6730
|
t_2 += "<";
|
|
6722
6731
|
t_2 += runtime.suppressValue(runtime.contextOrFrameLookup(context, frame, "textType"), env.opts.autoescape);
|
|
@@ -6732,10 +6741,14 @@ t_2 += runtime.suppressValue(runtime.memberLookup((l_params),"classes"), env.opt
|
|
|
6732
6741
|
t_2 += "\"";
|
|
6733
6742
|
;
|
|
6734
6743
|
}
|
|
6735
|
-
|
|
6736
|
-
t_2 += "
|
|
6737
|
-
|
|
6738
|
-
|
|
6744
|
+
if(runtime.contextOrFrameLookup(context, frame, "showNewLine")) {
|
|
6745
|
+
t_2 += " style=\"white-space: pre-line;\"";
|
|
6746
|
+
;
|
|
6747
|
+
}
|
|
6748
|
+
t_2 += runtime.suppressValue((lineno = 19, colno = 219, runtime.callWrap(t_9, "govcyLangAttribute", context, [runtime.memberLookup((l_params),"lang")])), env.opts.autoescape);
|
|
6749
|
+
t_2 += ">";
|
|
6750
|
+
t_2 += runtime.suppressValue((lineno = 19, colno = 259, runtime.callWrap(t_8, "govcyLocalizeContent", context, [runtime.memberLookup((l_params),"text"),runtime.memberLookup((l_params),"lang")])), env.opts.autoescape);
|
|
6751
|
+
t_2 += "</";
|
|
6739
6752
|
t_2 += runtime.suppressValue(runtime.contextOrFrameLookup(context, frame, "textType"), env.opts.autoescape);
|
|
6740
6753
|
t_2 += ">";
|
|
6741
6754
|
;
|
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
@param {string} lang The language used. Can be 'en','el'. Optional.
|
|
3
3
|
@param {object} text The text. Will escape text, Example `{en:"Content",el:"Περιεχομένο"}`
|
|
4
4
|
@param {string} type The type of the element. Can be `p`,`h1`,`h2`,`h3`,`h4`,`span`. Default is `p`
|
|
5
|
+
@param {boolean} showNewLine Whether to show new line characters on HTML using `style="white-space: pre-line;"`. Default is `false`
|
|
5
6
|
@param {string} id The elemen't id. Will escape text. Optional
|
|
6
7
|
@param {string} classes Additional classes to add to the outer div. Optional
|
|
7
8
|
@returns html Elements with sanitzed html
|
|
@@ -9,15 +10,14 @@
|
|
|
9
10
|
{% macro textElement(params) -%}
|
|
10
11
|
{# set default values #}
|
|
11
12
|
{%- set textType = params.type | default('p') -%}
|
|
13
|
+
{%- set showNewLine = params.showNewLine | default(false) -%}
|
|
12
14
|
{# text and type are mandatory #}
|
|
13
15
|
{%- if params.text -%}
|
|
14
16
|
{#- Import localizer from utilities -#}
|
|
15
17
|
{%- from "../utilities/govcyUtilities.njk" import govcyLocalizeContent, govcyLangAttribute -%}
|
|
16
18
|
{%- if textType == 'p' or textType == 'h1' or textType == 'h2' or textType == 'h3' or textType == 'h4' or textType == 'span' -%}
|
|
17
19
|
{%- set textTag = textType -%}
|
|
18
|
-
<{{ textType }}{% if params.id %} id="{{ params.id }}"{% endif %}{% if params.classes %} class="{{ params.classes }}"{% endif %}{{ govcyLangAttribute(params.lang) }}>
|
|
19
|
-
{{ govcyLocalizeContent(params.text, params.lang) }}
|
|
20
|
-
</{{ textType }}>
|
|
20
|
+
<{{ textType }}{% if params.id %} id="{{ params.id }}"{% endif %}{% if params.classes %} class="{{ params.classes }}"{% endif %}{% if showNewLine %} style="white-space: pre-line;"{% endif %}{{ govcyLangAttribute(params.lang) }}>{{ govcyLocalizeContent(params.text, params.lang) }}</{{ textType }}>
|
|
21
21
|
{%- endif -%}
|
|
22
22
|
{%- endif -%}
|
|
23
23
|
{%- endmacro %}
|