@trustme24/flext 2.0.0 → 2.0.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.
- package/README.md +13 -13
- package/dist/dialects/index.d.ts +0 -1
- package/dist/dialects/legacy-1-0-beta4.d.ts +7 -1
- package/dist/index.cjs +113 -111
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +2 -0
- package/dist/index.js +20 -20
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
- package/src/dialects/index.ts +0 -1
- package/src/dialects/legacy-1-0-beta4.ts +69 -1
- package/src/index.ts +8 -1
- package/dist/dialects/legacy-1-0-beta3.d.ts +0 -5
- package/src/dialects/legacy-1-0-beta3.ts +0 -7
package/README.md
CHANGED
|
@@ -12,9 +12,9 @@ In many systems, templates start simple and gradually become fragile: fields app
|
|
|
12
12
|
|
|
13
13
|
A Flext template can contain Markup, Metadata, Modules, and rendering hints in a single artifact. This makes templates easier to reuse, validate, and embed into larger systems such as document pipelines, reporting services, or contract generation platforms.
|
|
14
14
|
|
|
15
|
-
- [GitHub: TrustMe-kz/flext](https://github.com/TrustMe-kz/flext)
|
|
16
|
-
- [NPM: @trustme24/flext](https://www.npmjs.com/package/@trustme24/flext)
|
|
17
|
-
- [Demo: Available at CodeSandbox](https://codesandbox.io/p/devbox/trustme24-flext-f5x2hy)
|
|
15
|
+
- [GitHub: TrustMe-kz/flext](https://github.com/TrustMe-kz/flext)
|
|
16
|
+
- [NPM: @trustme24/flext](https://www.npmjs.com/package/@trustme24/flext)
|
|
17
|
+
- [Demo: Available at CodeSandbox](https://codesandbox.io/p/devbox/trustme24-flext-f5x2hy)
|
|
18
18
|
- [Documentation: Available at TrustMe Wiki](https://trustmekz.atlassian.net/wiki/external/MTUwYzM5NjUzNDE4NDViMGJlMTliOWEzNzM1Y2RiZWE)
|
|
19
19
|
|
|
20
20
|
---
|
|
@@ -46,17 +46,17 @@ Typical issues include: undocumented fields, incompatible template versions, dup
|
|
|
46
46
|
### A few common scenarios illustrate the problem:
|
|
47
47
|
|
|
48
48
|
1. **A template expects a field that is not provided at runtime. The result is either a broken document or silent incorrect output.**
|
|
49
|
-
Solution with Flext: The template can explicitly declare required fields using Metadata so missing data is detected early.
|
|
49
|
+
Solution with Flext: The template can explicitly declare required fields using Metadata so missing data is detected early.
|
|
50
50
|
|
|
51
51
|
————————————
|
|
52
52
|
|
|
53
53
|
2. **Multiple services use the same template but apply different helper logic or formatting rules.**
|
|
54
|
-
Solution with Flext: Templates can declare Module dependencies so rendering logic is predictable and consistent.
|
|
54
|
+
Solution with Flext: Templates can declare Module dependencies so rendering logic is predictable and consistent.
|
|
55
55
|
|
|
56
56
|
————————————
|
|
57
57
|
|
|
58
58
|
3. **Templates evolve but older documents still rely on previous versions.**
|
|
59
|
-
Solution with Flext: Templates can carry explicit Version information and compatibility rules.
|
|
59
|
+
Solution with Flext: Templates can carry explicit Version information and compatibility rules.
|
|
60
60
|
|
|
61
61
|
---
|
|
62
62
|
|
|
@@ -103,19 +103,19 @@ const template = `
|
|
|
103
103
|
{{!-- @syntax "1.0" --}}
|
|
104
104
|
{{!-- @use "put" --}}
|
|
105
105
|
{{!-- @group "data" --}}
|
|
106
|
-
{{!-- @field "data.
|
|
106
|
+
{{!-- @field "data.helloWorld" type="string" label="Hello World" required --}}
|
|
107
107
|
|
|
108
|
-
<p class="text-center
|
|
109
|
-
{{ put data.
|
|
108
|
+
<p class="text-center">
|
|
109
|
+
{{ put data.helloWorld 'No hello world...' }}
|
|
110
110
|
</p>
|
|
111
111
|
`;
|
|
112
112
|
|
|
113
113
|
const flext = new Flext(template, {
|
|
114
|
-
data: {
|
|
114
|
+
data: { helloWorld: 'Hello World!' },
|
|
115
115
|
});
|
|
116
116
|
|
|
117
117
|
console.log(flext.html); // <p class="...">Hello World!</p>
|
|
118
|
-
console.log(flext.model); // {"name":"data","$":[{"name":"
|
|
118
|
+
console.log(flext.model); // {"name":"data","$":[{"name":"helloWorld"}]}
|
|
119
119
|
```
|
|
120
120
|
|
|
121
121
|
> 💡 **In this example** the template carries additional information: Version, Field definition, and Module usage. This allows runtime tools to build a Data Model, validate input, and render HTML predictably.
|
|
@@ -128,7 +128,7 @@ console.log(flext.model); // {"name":"data","$":[{"name":"someField"}]}
|
|
|
128
128
|
|
|
129
129
|
**Flext** is intended for structured document generation. Common examples include contracts, invoices, reports, certificates, and internal document workflows. It is particularly useful when templates must be versioned, validated, reused across services, or rendered in multiple environments.
|
|
130
130
|
|
|
131
|
-
Flext can be used on its own, but it is also designed to serve as a core library inside larger systems. Related tools include [
|
|
131
|
+
Flext can be used on its own, but it is also designed to serve as a core library inside larger systems. Related tools include [Vue Flext](https://www.npmjs.com/package/vue-flext) for Vue integration, [flext2pdf](https://www.npmjs.com/package/flext2pdf) for HTML‑to‑PDF rendering, [Flext File](https://www.npmjs.com/package/flext-file) for portable document packaging and transfer, and some **Flext Service** for running document rendering as a microservice.
|
|
132
132
|
|
|
133
133
|
Together these components allow Flext to power full document pipelines while remaining a lightweight core library.
|
|
134
134
|
|
|
@@ -192,7 +192,7 @@ Directives / Modules
|
|
|
192
192
|
PDF / Preview / Data Model / Export
|
|
193
193
|
```
|
|
194
194
|
|
|
195
|
-
At runtime Flext parses the template, extracts Metadata, registers Modules, builds a Data Model, and generates preview. The output can then be passed to other tools to display, store, or generating PDF.
|
|
195
|
+
At runtime Flext parses the template, extracts Metadata, registers Modules, builds a Data Model, and generates preview. The output can then be passed to other tools to display, store, or generating PDF. Flext-based documents can also be packaged as `.flext` artifacts with [Flext File](https://www.npmjs.com/package/flext-file) for portable storage or transfer between systems.
|
|
196
196
|
|
|
197
197
|
- [Repo: More information about the repo can be found in ARCHITECTURE.md](https://github.com/TrustMe-kz/flext/blob/main/ARCHITECTURE.md)
|
|
198
198
|
- [Documentation: More information about the API is available at TrustMe Wiki](https://trustmekz.atlassian.net/wiki/external/MTUwYzM5NjUzNDE4NDViMGJlMTliOWEzNzM1Y2RiZWE)
|
package/dist/dialects/index.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AST } from '@handlebars/parser';
|
|
2
|
+
import { types, Dialect } from '@flext/core';
|
|
3
|
+
export declare const HANDLEBARS_COMMENT_BEGIN = "{{!--";
|
|
4
|
+
export declare const DIALECT_MACRO = "syntax";
|
|
5
|
+
export declare const LEGACY_DIALECT_MACRO = "v";
|
|
2
6
|
export declare class LegacyDialect extends Dialect {
|
|
3
7
|
name: string;
|
|
8
|
+
testAst(val: AST.Program, doWarn?: boolean | null): boolean;
|
|
9
|
+
templateToStandard(template: types.Template): types.StandardTemplate;
|
|
4
10
|
}
|
|
5
11
|
export default LegacyDialect;
|