@itrocks/template 0.2.3 → 0.2.4
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.
- package/README.md +3 -0
- package/cjs/template.d.ts +3 -3
- package/cjs/template.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -460,6 +460,9 @@ You can apply translations via a plugin without having to mark texts explicitly.
|
|
|
460
460
|
Composite translations, where certain parts of a phrase are replaced by translated elements or non-literal data,
|
|
461
461
|
are supported.
|
|
462
462
|
|
|
463
|
+
Textual attributes are literals too: `alt`, `aria-label`, `enterkeyhint`, `label`, `lang`, `placeholder`, `srcdoc` and
|
|
464
|
+
`title` are passed to [`applyLiterals()`](#internationalization-i18n) while structural attributes remain unchanged.
|
|
465
|
+
|
|
463
466
|
Example of a custom template class that applies translations:
|
|
464
467
|
```ts
|
|
465
468
|
import { Template } from '@itrocks/template'
|
package/cjs/template.d.ts
CHANGED
|
@@ -26,8 +26,8 @@ export declare class HtmlResponse {
|
|
|
26
26
|
toString(): string;
|
|
27
27
|
}
|
|
28
28
|
export declare class Template {
|
|
29
|
-
data?: any;
|
|
30
|
-
containerData?: any;
|
|
29
|
+
data?: any | undefined;
|
|
30
|
+
containerData?: any | undefined;
|
|
31
31
|
blockBack: number;
|
|
32
32
|
blockStack: BlockStackEntry[];
|
|
33
33
|
doExpression: boolean;
|
|
@@ -64,7 +64,7 @@ export declare class Template {
|
|
|
64
64
|
onTagClose?: (name: string) => void;
|
|
65
65
|
parsers: VariableParser[];
|
|
66
66
|
prefixes: string;
|
|
67
|
-
constructor(data?: any, containerData?: any);
|
|
67
|
+
constructor(data?: any | undefined, containerData?: any | undefined);
|
|
68
68
|
applyLiterals(text: string, parts?: string[]): string;
|
|
69
69
|
closeTag(shouldInLiteral: boolean, targetIndex: number): boolean;
|
|
70
70
|
combineLiterals(text: string, parts?: string[]): string;
|
package/cjs/template.js
CHANGED
|
@@ -62,7 +62,7 @@ class Template {
|
|
|
62
62
|
// Inline elements are replaced by $1 when in literal.
|
|
63
63
|
inlineElements = new sorted_array_1.SortedArray('a', 'abbr', 'acronym', 'b', 'bdo', 'big', 'button', 'cite', 'code', 'data', 'del', 'dfn', 'em', 'font', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'map', 'mark', 'meter', 'object', 'optgroup', 'option', 'output', 'picture', 'q', 'rt', 'samp', 'select', 'small', 'span', 'strike', 'strong', 'sub', 'sup', 'svg', 'time', 'tspan', 'tt', 'u', 'var', 'wbr');
|
|
64
64
|
// These attribute values are literals.
|
|
65
|
-
literalAttributes = new sorted_array_1.SortedArray('alt', 'enterkeyhint', 'label', 'lang', 'placeholder', 'srcdoc', 'title');
|
|
65
|
+
literalAttributes = new sorted_array_1.SortedArray('alt', 'aria-label', 'enterkeyhint', 'label', 'lang', 'placeholder', 'srcdoc', 'title');
|
|
66
66
|
// These element contents are literals.
|
|
67
67
|
literalElements = new sorted_array_1.SortedArray('a', 'abbr', 'acronym', 'article', 'aside', 'b', 'bdi', 'bdo', 'big', 'blockquote', 'body', 'br', 'button', 'caption', 'center', 'cite', 'data', 'datalist', 'dd', 'del', 'desc', 'details', 'dfn', 'dialog', 'div', 'dt', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hr', 'i', 'iframe', 'ins', 'keygen', 'label', 'legend', 'li', 'main', 'mark', 'menuitem', 'meter', 'nav', 'noframes', 'noscript', 'optgroup', 'option', 'p', 'pre', 'q', 'rb', 's', 'section', 'select', 'small', 'span', 'strike', 'strong', 'sub', 'summary', 'sup', 'td', 'template', 'text', 'textarea', 'textpath', 'th', 'time', 'title', 'tspan', 'u', 'wbr');
|
|
68
68
|
// These elements have no closing tag.
|
package/package.json
CHANGED