@accordproject/template-engine 1.0.0 → 1.0.2
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/package.json +5 -2
- package/.github/workflows/npm-publish.yml +0 -37
- package/assets/template-compilation.png +0 -0
- package/assets/template-interpreter.png +0 -0
- package/src/Common.ts +0 -58
- package/src/TemplateMarkInterpreter.ts +0 -420
- package/src/TemplateMarkToJavaScriptCompiler.ts +0 -99
- package/src/TemplateMarkToTypeScriptCompiler.ts +0 -276
- package/src/TypeScriptCompilationContext.ts +0 -73
- package/src/TypeScriptRuntime.ts +0 -64
- package/src/TypeScriptToJavaScriptCompiler.ts +0 -59
- package/src/compilers/Clause.ts +0 -63
- package/src/compilers/Common.ts +0 -215
- package/src/compilers/Conditional.ts +0 -53
- package/src/compilers/ContractDefinition.ts +0 -31
- package/src/compilers/FormattedVariable.ts +0 -41
- package/src/compilers/Formula.ts +0 -36
- package/src/compilers/Join.ts +0 -33
- package/src/compilers/ListBlock.ts +0 -55
- package/src/compilers/NodeCompilers.ts +0 -90
- package/src/compilers/Optional.ts +0 -65
- package/src/compilers/Variable.ts +0 -40
- package/src/compilers/With.ts +0 -37
- package/src/drafting/Boolean/index.ts +0 -26
- package/src/drafting/DateTime/index.ts +0 -28
- package/src/drafting/Double/format.ts +0 -50
- package/src/drafting/Double/index.ts +0 -30
- package/src/drafting/Integer/format.ts +0 -41
- package/src/drafting/Integer/index.ts +0 -32
- package/src/drafting/Long/index.ts +0 -30
- package/src/drafting/MonetaryAmount/currencycode.ts +0 -49
- package/src/drafting/MonetaryAmount/index.ts +0 -73
- package/src/drafting/String/index.ts +0 -22
- package/src/drafting/index.ts +0 -31
- package/src/index.ts +0 -15
- package/src/markdown-common.d.ts +0 -14
- package/src/model-gen/concerto.metamodel@1.0.0.ts +0 -267
- package/src/model-gen/concerto@1.0.0.ts +0 -71
- package/src/model-gen/org.accordproject.ciceromark@0.6.0.ts +0 -82
- package/src/model-gen/org.accordproject.commonmark@0.5.0.ts +0 -159
- package/src/model-gen/org.accordproject.templatemark@0.4.0.ts +0 -119
- package/tsconfig.build.json +0 -4
- package/tsconfig.json +0 -101
package/src/compilers/Common.ts
DELETED
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
* you may not use this file except in compliance with the License.
|
|
4
|
-
* You may obtain a copy of the License at
|
|
5
|
-
*
|
|
6
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
*
|
|
8
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
* See the License for the specific language governing permissions and
|
|
12
|
-
* limitations under the License.
|
|
13
|
-
*/
|
|
14
|
-
import { INode } from '../model-gen/org.accordproject.commonmark@0.5.0';
|
|
15
|
-
import { CommonMarkModel,TemplateMarkModel,CiceroMarkModel } from '@accordproject/markdown-common';
|
|
16
|
-
import { FileWriter } from '@accordproject/concerto-util';
|
|
17
|
-
import { ClassDeclaration, ModelUtil } from '@accordproject/concerto-core';
|
|
18
|
-
import { ProcessingFunction } from '../TemplateMarkToTypeScriptCompiler';
|
|
19
|
-
|
|
20
|
-
export function writeDebug(fw:FileWriter, level:number, concept:any) {
|
|
21
|
-
fw.writeLine(level, `// ${ModelUtil.getShortName(concept.$class)} ${concept.name ? `(${concept.name})` : ''}`);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const RUNTIME_DIR = 'runtime';
|
|
25
|
-
|
|
26
|
-
export function writeImports(fw:FileWriter, level:number, templateClass:ClassDeclaration) {
|
|
27
|
-
fw.writeLine(level, `import * as CommonMark from './${CommonMarkModel.NAMESPACE}';`);
|
|
28
|
-
fw.writeLine(level, `import * as CiceroMark from './${CiceroMarkModel.NAMESPACE}';`);
|
|
29
|
-
fw.writeLine(level, `import * as TemplateModel from './${templateClass.getNamespace()}';`);
|
|
30
|
-
fw.writeLine(level, 'import dayjs from \'dayjs\';');
|
|
31
|
-
fw.writeLine(level, 'import * as UserCode from \'./usercode\';');
|
|
32
|
-
fw.writeLine(level, `import { draftingMap as $draftingMap } from './${RUNTIME_DIR}/drafting';`);
|
|
33
|
-
fw.writeLine(level, `import * as Runtime from './${RUNTIME_DIR}/TypeScriptRuntime';`);
|
|
34
|
-
}
|
|
35
|
-
export function writeProlog(fw:FileWriter, level:number, templateClass:ClassDeclaration) {
|
|
36
|
-
fw.writeLine(level, `export function generator(data:TemplateModel.I${templateClass.getName()}, library:any, now:dayjs.Dayjs) : CommonMark.IDocument {`);
|
|
37
|
-
fw.writeLine(level, `const docNode = {$class: '${CommonMarkModel.NAMESPACE}.Document', xmlns: '${CommonMarkModel.NAMESPACE}', nodes: []} as CommonMark.INode;`);
|
|
38
|
-
fw.writeLine(level, 'const $nodes:CommonMark.INode[] = [];'); // the stack of output CiceroMark nodes
|
|
39
|
-
fw.writeLine(level, 'const $data:any[] = [];'); // the stack of 'this' used for data access
|
|
40
|
-
fw.writeLine(level, 'let $result:any = docNode;'); // document root, or the return value
|
|
41
|
-
fw.writeLine(level, 'Runtime.push($data, data);'); // push the 'data' to the stack so we have an initial 'this';
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function writeEpilog(fw:FileWriter, level:number) {
|
|
45
|
-
fw.writeLine(level, 'return $result as CommonMark.IDocument;');
|
|
46
|
-
fw.writeLine(level, '}');
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// allows us to declare local variables without fear of collision
|
|
50
|
-
export function writeOpenGenerateScope(fw:FileWriter, level:number) {
|
|
51
|
-
fw.writeLine(level, '$result = (() => {');
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// closes the scope, calling the anon-function
|
|
55
|
-
// and then pushes the result as a child of the last element of $nodes
|
|
56
|
-
export function writeCloseGenerateScope(fw:FileWriter, level:number) {
|
|
57
|
-
fw.writeLine(level, '})();');
|
|
58
|
-
fw.writeLine(level, 'Runtime.addChild($nodes, $result);');
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// save $curNode into $stack, so we can pop it when the scope closes
|
|
62
|
-
export function writeOpenNodeScope(fw:FileWriter, level:number) {
|
|
63
|
-
fw.writeLine(level, 'Runtime.push($nodes, $result);');
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// closes the scope, popping the stack and setting $curNode
|
|
67
|
-
export function writeCloseNodeScope(fw:FileWriter, level:number) {
|
|
68
|
-
fw.writeLine(level, '$result = Runtime.pop($nodes);');
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// save $curNode into $stack, so we can pop it when the scope closes
|
|
72
|
-
export function writeOpenDataScope(fw:FileWriter, level:number, name:string, allowUndefined=false) {
|
|
73
|
-
fw.writeLine(level, `Runtime.push($data, Runtime.peekProperty($data, '${name}', ${allowUndefined}));`);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// closes the scope, popping the stack and setting $curNode
|
|
77
|
-
export function writeCloseDataScope(fw:FileWriter, level:number) {
|
|
78
|
-
fw.writeLine(level, 'Runtime.pop($data);');
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export function getTypeScriptType(ctoFqn: string): string {
|
|
82
|
-
const ns = ModelUtil.getNamespace(ctoFqn);
|
|
83
|
-
const type = ModelUtil.getShortName(ctoFqn);
|
|
84
|
-
|
|
85
|
-
if (ns === CommonMarkModel.NAMESPACE) {
|
|
86
|
-
return `CommonMark.I${type}`;
|
|
87
|
-
}
|
|
88
|
-
else if (ns === CiceroMarkModel.NAMESPACE) {
|
|
89
|
-
return `CiceroMark.I${type}`;
|
|
90
|
-
}
|
|
91
|
-
else if (ns === TemplateMarkModel.NAMESPACE) {
|
|
92
|
-
return `CiceroMark.I${type.substring(0, type.length - 'Definition'.length)}`;
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
throw new Error(`No type mapping for ${ctoFqn}`);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Map of a node from template mark to ciceromark
|
|
101
|
-
* @param {INode} templateMarkNode the template mark.
|
|
102
|
-
* @param {boolean} deep when deep is false (the default) child nodes are not copied
|
|
103
|
-
* @returns {INode} the mapped node
|
|
104
|
-
*/
|
|
105
|
-
export function makeCiceroMark(templateMarkNode:INode, deep=false): INode {
|
|
106
|
-
if(!templateMarkNode.$class) {
|
|
107
|
-
throw new Error('Not a concerto type.');
|
|
108
|
-
}
|
|
109
|
-
const json = JSON.parse(JSON.stringify(templateMarkNode));
|
|
110
|
-
delete json.elementType;
|
|
111
|
-
if(!deep) {
|
|
112
|
-
delete json.nodes;
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
if(json.nodes) {
|
|
116
|
-
json.nodes = json.nodes.map((n:INode) => makeCiceroMark(n,deep));
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const ns = ModelUtil.getNamespace(json.$class);
|
|
121
|
-
const type = ModelUtil.getShortName(json.$class);
|
|
122
|
-
|
|
123
|
-
if (ns === TemplateMarkModel.NAMESPACE) {
|
|
124
|
-
json.$class = `${CiceroMarkModel.NAMESPACE}.${type.substring(0, type.length - 'Definition'.length)}`;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return json;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export interface INodeCompiler {
|
|
131
|
-
enter(fw:FileWriter, level:number, templateMarkNode:INode) : void;
|
|
132
|
-
generate(fw:FileWriter, level:number, templateMarkNode:INode, doIt:ProcessingFunction) : void;
|
|
133
|
-
exit(fw:FileWriter, level:number, templateMarkNode:INode) : void;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* A node compiler that allows code to run on node enter, exit and
|
|
138
|
-
* with a generate method to generate code for the node.
|
|
139
|
-
*/
|
|
140
|
-
export abstract class AbstractComplexCompiler implements INodeCompiler {
|
|
141
|
-
|
|
142
|
-
leaf:boolean;
|
|
143
|
-
|
|
144
|
-
constructor(leaf:boolean) {
|
|
145
|
-
this.leaf = leaf;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
isLeaf() : boolean {
|
|
149
|
-
return this.leaf;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
enter(fw:FileWriter, level:number,templateMarkNode:INode) {
|
|
153
|
-
writeDebug(fw, level, templateMarkNode);
|
|
154
|
-
writeOpenNodeScope(fw,level);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
abstract generate(fw:FileWriter, level:number, templateMarkNode:INode, doIt:ProcessingFunction) : void;
|
|
158
|
-
|
|
159
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
160
|
-
exit(fw:FileWriter, level:number) {
|
|
161
|
-
writeCloseNodeScope(fw,level);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* A node compiler that allows a JSON node to be constructed from
|
|
167
|
-
* the data in a templatemark node.
|
|
168
|
-
*/
|
|
169
|
-
export abstract class AbstractSimpleCompiler extends AbstractComplexCompiler {
|
|
170
|
-
|
|
171
|
-
constructor(leaf:boolean) {
|
|
172
|
-
super(leaf);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
abstract getNode(templateMarkNode:INode):INode;
|
|
176
|
-
|
|
177
|
-
generate(fw:FileWriter, level:number, templateMarkNode:INode) {
|
|
178
|
-
const node = this.getNode(templateMarkNode);
|
|
179
|
-
if(this.isLeaf()) {
|
|
180
|
-
node.nodes = []; // we are a leaf node, null out child nodes
|
|
181
|
-
}
|
|
182
|
-
writeOpenGenerateScope(fw,level);
|
|
183
|
-
fw.writeLine(level, `return ${JSON.stringify(node)} as ${getTypeScriptType(node.$class)};`);
|
|
184
|
-
writeCloseGenerateScope(fw,level);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* PassThroughNode simply maps data from TemplateMark to
|
|
190
|
-
* CiceroMark, updating namespaces but otherwise leaving
|
|
191
|
-
* the data alone.
|
|
192
|
-
*/
|
|
193
|
-
export class PassThrough extends AbstractSimpleCompiler {
|
|
194
|
-
constructor(leaf:boolean) {
|
|
195
|
-
super(leaf);
|
|
196
|
-
}
|
|
197
|
-
getNode(templateMarkNode:INode):INode {
|
|
198
|
-
return makeCiceroMark(templateMarkNode) as INode;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Ignore doesn't write any output for a node type
|
|
204
|
-
*/
|
|
205
|
-
export class Ignore implements INodeCompiler {
|
|
206
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
207
|
-
enter(fw: FileWriter, level: number, templateMarkNode: INode): void {
|
|
208
|
-
}
|
|
209
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
210
|
-
generate(fw: FileWriter, level: number, templateMarkNode: INode): void {
|
|
211
|
-
}
|
|
212
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
213
|
-
exit(fw: FileWriter, level: number, templateMarkNode: INode): void {
|
|
214
|
-
}
|
|
215
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
* you may not use this file except in compliance with the License.
|
|
4
|
-
* You may obtain a copy of the License at
|
|
5
|
-
*
|
|
6
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
*
|
|
8
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
* See the License for the specific language governing permissions and
|
|
12
|
-
* limitations under the License.
|
|
13
|
-
*/
|
|
14
|
-
import { FileWriter } from '@accordproject/concerto-util';
|
|
15
|
-
import { TemplateMarkModel } from '@accordproject/markdown-common';
|
|
16
|
-
import { IConditional } from '../model-gen/org.accordproject.ciceromark@0.6.0';
|
|
17
|
-
import { IConditionalDefinition } from '../model-gen/org.accordproject.templatemark@0.4.0';
|
|
18
|
-
import { AbstractComplexCompiler, getTypeScriptType, makeCiceroMark, writeCloseDataScope, writeCloseGenerateScope, writeOpenDataScope, writeOpenGenerateScope } from './Common';
|
|
19
|
-
|
|
20
|
-
interface INamedConditionalDefinition extends IConditionalDefinition {
|
|
21
|
-
readonly functionName: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export class Conditional extends AbstractComplexCompiler {
|
|
25
|
-
static TYPE = `${TemplateMarkModel.NAMESPACE}.ConditionalDefinition`;
|
|
26
|
-
constructor() {
|
|
27
|
-
super(false);
|
|
28
|
-
}
|
|
29
|
-
generate(fw:FileWriter, level:number, templateMarkNode:INamedConditionalDefinition) {
|
|
30
|
-
const clone = makeCiceroMark(templateMarkNode, true) as IConditional;
|
|
31
|
-
delete (clone as any).condition;
|
|
32
|
-
delete (clone as any).dependencies;
|
|
33
|
-
delete (clone as any).functionName;
|
|
34
|
-
clone.isTrue = true;
|
|
35
|
-
writeOpenGenerateScope(fw,level);
|
|
36
|
-
if(templateMarkNode.condition) {
|
|
37
|
-
fw.writeLine(level, `const isTrue:boolean = UserCode.${templateMarkNode.functionName}(data,library,now)`);
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
writeOpenDataScope(fw,level,templateMarkNode.name);
|
|
41
|
-
fw.writeLine(level, 'const isTrue:boolean = Runtime.peek($data);');
|
|
42
|
-
writeCloseDataScope(fw,level);
|
|
43
|
-
}
|
|
44
|
-
fw.writeLine(level, `const curNode = ${JSON.stringify(clone)} as ${getTypeScriptType(templateMarkNode.$class)};`);
|
|
45
|
-
fw.writeLine(level, '(curNode as CiceroMark.IConditional).isTrue = isTrue;');
|
|
46
|
-
fw.writeLine(level, 'return curNode;');
|
|
47
|
-
writeCloseGenerateScope(fw,level);
|
|
48
|
-
delete templateMarkNode.condition;
|
|
49
|
-
delete (templateMarkNode as any).whenTrue;
|
|
50
|
-
delete (templateMarkNode as any).whenFalse;
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
* you may not use this file except in compliance with the License.
|
|
4
|
-
* You may obtain a copy of the License at
|
|
5
|
-
*
|
|
6
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
*
|
|
8
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
* See the License for the specific language governing permissions and
|
|
12
|
-
* limitations under the License.
|
|
13
|
-
*/
|
|
14
|
-
import { TemplateMarkModel,CiceroMarkModel } from '@accordproject/markdown-common';
|
|
15
|
-
import { IContract } from '../model-gen/org.accordproject.ciceromark@0.6.0';
|
|
16
|
-
import { IContractDefinition } from '../model-gen/org.accordproject.templatemark@0.4.0';
|
|
17
|
-
import { AbstractSimpleCompiler } from './Common';
|
|
18
|
-
|
|
19
|
-
export class ContractDefinition extends AbstractSimpleCompiler {
|
|
20
|
-
static TYPE = `${TemplateMarkModel.NAMESPACE}.ContractDefinition`;
|
|
21
|
-
constructor() {
|
|
22
|
-
super(false);
|
|
23
|
-
}
|
|
24
|
-
getNode(templateMarkNode:IContractDefinition) {
|
|
25
|
-
return {
|
|
26
|
-
$class: `${CiceroMarkModel.NAMESPACE}.Contract`,
|
|
27
|
-
name: templateMarkNode.name,
|
|
28
|
-
nodes: []
|
|
29
|
-
} as IContract;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
* you may not use this file except in compliance with the License.
|
|
4
|
-
* You may obtain a copy of the License at
|
|
5
|
-
*
|
|
6
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
*
|
|
8
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
* See the License for the specific language governing permissions and
|
|
12
|
-
* limitations under the License.
|
|
13
|
-
*/
|
|
14
|
-
import { FileWriter } from '@accordproject/concerto-util';
|
|
15
|
-
import { TemplateMarkModel } from '@accordproject/markdown-common';
|
|
16
|
-
import { IFormattedVariable } from '../model-gen/org.accordproject.ciceromark@0.6.0';
|
|
17
|
-
import { IFormattedVariableDefinition } from '../model-gen/org.accordproject.templatemark@0.4.0';
|
|
18
|
-
import { AbstractComplexCompiler, getTypeScriptType, makeCiceroMark, writeCloseDataScope, writeCloseGenerateScope, writeOpenDataScope, writeOpenGenerateScope } from './Common';
|
|
19
|
-
|
|
20
|
-
export class FormattedVariable extends AbstractComplexCompiler {
|
|
21
|
-
static TYPE = `${TemplateMarkModel.NAMESPACE}.FormattedVariableDefinition`;
|
|
22
|
-
constructor() {
|
|
23
|
-
super(true);
|
|
24
|
-
}
|
|
25
|
-
generate(fw:FileWriter, level:number, templateMarkNode:IFormattedVariableDefinition) {
|
|
26
|
-
const clone = makeCiceroMark(templateMarkNode) as IFormattedVariable;
|
|
27
|
-
writeOpenGenerateScope(fw,level);
|
|
28
|
-
if(templateMarkNode.name !== 'this') {
|
|
29
|
-
writeOpenDataScope(fw,level,templateMarkNode.name);
|
|
30
|
-
}
|
|
31
|
-
fw.writeLine(level, `const drafter = $draftingMap.get('${templateMarkNode.elementType}');`);
|
|
32
|
-
fw.writeLine(level, `const text = drafter ? drafter(Runtime.peek($data), '${templateMarkNode.format}') : JSON.stringify(Runtime.peek($data)) as string;`);
|
|
33
|
-
if(templateMarkNode.name !== 'this') {
|
|
34
|
-
writeCloseDataScope(fw,level);
|
|
35
|
-
}
|
|
36
|
-
fw.writeLine(level, `const variable:any = ${JSON.stringify(clone)};`);
|
|
37
|
-
fw.writeLine(level, 'variable.value = text;');
|
|
38
|
-
fw.writeLine(level, `return variable as ${getTypeScriptType(clone.$class)};`);
|
|
39
|
-
writeCloseGenerateScope(fw,level);
|
|
40
|
-
}
|
|
41
|
-
}
|
package/src/compilers/Formula.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
* you may not use this file except in compliance with the License.
|
|
4
|
-
* You may obtain a copy of the License at
|
|
5
|
-
*
|
|
6
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
*
|
|
8
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
* See the License for the specific language governing permissions and
|
|
12
|
-
* limitations under the License.
|
|
13
|
-
*/
|
|
14
|
-
import { FileWriter } from '@accordproject/concerto-util';
|
|
15
|
-
import { TemplateMarkModel } from '@accordproject/markdown-common';
|
|
16
|
-
import { IFormula } from '../model-gen/org.accordproject.ciceromark@0.6.0';
|
|
17
|
-
import { IFormulaDefinition } from '../model-gen/org.accordproject.templatemark@0.4.0';
|
|
18
|
-
import { AbstractComplexCompiler, getTypeScriptType, makeCiceroMark, writeCloseGenerateScope, writeOpenGenerateScope } from './Common';
|
|
19
|
-
|
|
20
|
-
export class Formula extends AbstractComplexCompiler {
|
|
21
|
-
static TYPE = `${TemplateMarkModel.NAMESPACE}.FormulaDefinition`;
|
|
22
|
-
constructor() {
|
|
23
|
-
super(true);
|
|
24
|
-
}
|
|
25
|
-
generate(fw:FileWriter, level:number, templateMarkNode:IFormulaDefinition) {
|
|
26
|
-
const clone = makeCiceroMark(templateMarkNode) as IFormula;
|
|
27
|
-
writeOpenGenerateScope(fw,level);
|
|
28
|
-
fw.writeLine(level, `const formulaResult = UserCode.${templateMarkNode.name}(data,library,now);`);
|
|
29
|
-
fw.writeLine(level, 'const text = JSON.stringify(formulaResult);');
|
|
30
|
-
fw.writeLine(level, `const formula:any = ${JSON.stringify(clone)};`);
|
|
31
|
-
fw.writeLine(level, 'formula.value = text;');
|
|
32
|
-
fw.writeLine(level, `formula.code = ${JSON.stringify(templateMarkNode.code.contents)};`); // HACK - update model
|
|
33
|
-
fw.writeLine(level, `return formula as ${getTypeScriptType(clone.$class)};`);
|
|
34
|
-
writeCloseGenerateScope(fw,level);
|
|
35
|
-
}
|
|
36
|
-
}
|
package/src/compilers/Join.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
* you may not use this file except in compliance with the License.
|
|
4
|
-
* You may obtain a copy of the License at
|
|
5
|
-
*
|
|
6
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
*
|
|
8
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
* See the License for the specific language governing permissions and
|
|
12
|
-
* limitations under the License.
|
|
13
|
-
*/
|
|
14
|
-
import { FileWriter } from '@accordproject/concerto-util';
|
|
15
|
-
import { TemplateMarkModel,CommonMarkModel } from '@accordproject/markdown-common';
|
|
16
|
-
import { IJoinDefinition } from '../model-gen/org.accordproject.templatemark@0.4.0';
|
|
17
|
-
import { AbstractComplexCompiler, getTypeScriptType, writeCloseDataScope, writeCloseGenerateScope, writeOpenDataScope, writeOpenGenerateScope } from './Common';
|
|
18
|
-
|
|
19
|
-
export class Join extends AbstractComplexCompiler {
|
|
20
|
-
static TYPE = `${TemplateMarkModel.NAMESPACE}.JoinDefinition`;
|
|
21
|
-
constructor() {
|
|
22
|
-
super(true);
|
|
23
|
-
}
|
|
24
|
-
generate(fw:FileWriter, level:number, templateMarkNode:IJoinDefinition) {
|
|
25
|
-
writeOpenGenerateScope(fw,level);
|
|
26
|
-
writeOpenDataScope(fw,level,templateMarkNode.name);
|
|
27
|
-
fw.writeLine(level, `const text = Runtime.peek($data).join('${templateMarkNode.separator}');`);
|
|
28
|
-
writeCloseDataScope(fw,level);
|
|
29
|
-
fw.writeLine(level, `return { $class: '${CommonMarkModel.NAMESPACE}.Text', text: text } as ${getTypeScriptType(CommonMarkModel.NAMESPACE + '.Text')};`);
|
|
30
|
-
writeCloseGenerateScope(fw,level);
|
|
31
|
-
delete templateMarkNode.nodes; // ignore child nodes, like {{this}}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
* you may not use this file except in compliance with the License.
|
|
4
|
-
* You may obtain a copy of the License at
|
|
5
|
-
*
|
|
6
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
*
|
|
8
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
* See the License for the specific language governing permissions and
|
|
12
|
-
* limitations under the License.
|
|
13
|
-
*/
|
|
14
|
-
import { FileWriter } from '@accordproject/concerto-util';
|
|
15
|
-
import { TemplateMarkModel } from '@accordproject/markdown-common';
|
|
16
|
-
import { ProcessingFunction } from '../TemplateMarkToTypeScriptCompiler';
|
|
17
|
-
import { IList } from '../model-gen/org.accordproject.commonmark@0.5.0';
|
|
18
|
-
import { IListBlockDefinition, IWithDefinition } from '../model-gen/org.accordproject.templatemark@0.4.0';
|
|
19
|
-
import { AbstractComplexCompiler, getTypeScriptType, makeCiceroMark, writeCloseDataScope, writeCloseGenerateScope, writeCloseNodeScope, writeDebug, writeOpenDataScope, writeOpenGenerateScope, writeOpenNodeScope } from './Common';
|
|
20
|
-
|
|
21
|
-
export class ListBlock extends AbstractComplexCompiler {
|
|
22
|
-
static TYPE = `${TemplateMarkModel.NAMESPACE}.ListBlockDefinition`;
|
|
23
|
-
constructor() {
|
|
24
|
-
super(false);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
enter(fw:FileWriter, level:number,templateMarkNode:IWithDefinition) {
|
|
28
|
-
writeDebug(fw, level, templateMarkNode);
|
|
29
|
-
writeOpenNodeScope(fw,level);
|
|
30
|
-
writeOpenDataScope(fw,level,templateMarkNode.name);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
generate(fw:FileWriter, level:number, templateMarkNode:IListBlockDefinition, doIt:ProcessingFunction) {
|
|
34
|
-
if(templateMarkNode?.nodes?.[0]) {
|
|
35
|
-
const clone = makeCiceroMark(templateMarkNode?.nodes?.[0]) as IList;
|
|
36
|
-
writeOpenGenerateScope(fw, level);
|
|
37
|
-
fw.writeLine(level, `const result = ${JSON.stringify(clone)} as ${getTypeScriptType(templateMarkNode.$class)};`);
|
|
38
|
-
fw.writeLine(level, 'Runtime.peek($data).forEach( (item:any) => {');
|
|
39
|
-
fw.writeLine(level, 'Runtime.push($data,item);');
|
|
40
|
-
if(templateMarkNode.nodes?.[0].nodes?.[0]) {
|
|
41
|
-
doIt(fw, level+1, templateMarkNode.nodes[0].nodes[0]);
|
|
42
|
-
delete templateMarkNode.nodes; // already handled children ^^^
|
|
43
|
-
}
|
|
44
|
-
fw.writeLine(level, 'Runtime.pop($data);');
|
|
45
|
-
fw.writeLine(level, '});');
|
|
46
|
-
fw.writeLine(level, 'return result;');
|
|
47
|
-
writeCloseGenerateScope(fw, level);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
exit(fw:FileWriter, level:number) {
|
|
52
|
-
writeCloseDataScope(fw,level);
|
|
53
|
-
writeCloseNodeScope(fw,level);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
* you may not use this file except in compliance with the License.
|
|
4
|
-
* You may obtain a copy of the License at
|
|
5
|
-
*
|
|
6
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
*
|
|
8
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
* See the License for the specific language governing permissions and
|
|
12
|
-
* limitations under the License.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import { CommonMarkModel,TemplateMarkModel } from '@accordproject/markdown-common';
|
|
16
|
-
|
|
17
|
-
import { Clause } from './Clause';
|
|
18
|
-
import { Ignore, INodeCompiler, PassThrough } from './Common';
|
|
19
|
-
import { Conditional } from './Conditional';
|
|
20
|
-
import { ContractDefinition } from './ContractDefinition';
|
|
21
|
-
import { FormattedVariable } from './FormattedVariable';
|
|
22
|
-
import { Formula } from './Formula';
|
|
23
|
-
import { Join } from './Join';
|
|
24
|
-
import { ListBlock } from './ListBlock';
|
|
25
|
-
import { Optional } from './Optional';
|
|
26
|
-
import { Variable } from './Variable';
|
|
27
|
-
import { With } from './With';
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Registry of node compilers
|
|
31
|
-
*/
|
|
32
|
-
const NODE_COMPILERS:Record<string,INodeCompiler> = {
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
// templatemark
|
|
36
|
-
NODE_COMPILERS[ContractDefinition.TYPE] = new ContractDefinition();
|
|
37
|
-
NODE_COMPILERS[Variable.TYPE] = new Variable();
|
|
38
|
-
NODE_COMPILERS[FormattedVariable.TYPE] = new FormattedVariable();
|
|
39
|
-
NODE_COMPILERS[Formula.TYPE] = new Formula();
|
|
40
|
-
NODE_COMPILERS[Conditional.TYPE] = new Conditional();
|
|
41
|
-
NODE_COMPILERS[Join.TYPE] = new Join();
|
|
42
|
-
NODE_COMPILERS[With.TYPE] = new With();
|
|
43
|
-
NODE_COMPILERS[Clause.TYPE] = new Clause();
|
|
44
|
-
NODE_COMPILERS[Optional.TYPE] = new Optional();
|
|
45
|
-
NODE_COMPILERS[ListBlock.TYPE] = new ListBlock();
|
|
46
|
-
|
|
47
|
-
// ignored
|
|
48
|
-
NODE_COMPILERS[`${TemplateMarkModel.NAMESPACE}.Code`] = new Ignore();
|
|
49
|
-
NODE_COMPILERS[`${CommonMarkModel.NAMESPACE}.Document`] = new Ignore();
|
|
50
|
-
|
|
51
|
-
// commonmark
|
|
52
|
-
NODE_COMPILERS[`${CommonMarkModel.NAMESPACE}.Paragraph`] = new PassThrough(false);
|
|
53
|
-
NODE_COMPILERS[`${CommonMarkModel.NAMESPACE}.Text`] = new PassThrough(true);
|
|
54
|
-
NODE_COMPILERS[`${CommonMarkModel.NAMESPACE}.Attribute`] = new PassThrough(false);
|
|
55
|
-
NODE_COMPILERS[`${CommonMarkModel.NAMESPACE}.TagInfo`] = new PassThrough(false);
|
|
56
|
-
NODE_COMPILERS[`${CommonMarkModel.NAMESPACE}.CodeBlock`] = new PassThrough(false);
|
|
57
|
-
NODE_COMPILERS[`${CommonMarkModel.NAMESPACE}.Code`] = new PassThrough(false);
|
|
58
|
-
NODE_COMPILERS[`${CommonMarkModel.NAMESPACE}.HtmlInline`] = new PassThrough(false);
|
|
59
|
-
NODE_COMPILERS[`${CommonMarkModel.NAMESPACE}.HtmlBlock`] = new PassThrough(false);
|
|
60
|
-
NODE_COMPILERS[`${CommonMarkModel.NAMESPACE}.Emph`] = new PassThrough(false);
|
|
61
|
-
NODE_COMPILERS[`${CommonMarkModel.NAMESPACE}.Strong`] = new PassThrough(false);
|
|
62
|
-
NODE_COMPILERS[`${CommonMarkModel.NAMESPACE}.BlockQuote`] = new PassThrough(false);
|
|
63
|
-
NODE_COMPILERS[`${CommonMarkModel.NAMESPACE}.Heading`] = new PassThrough(false);
|
|
64
|
-
NODE_COMPILERS[`${CommonMarkModel.NAMESPACE}.ThematicBreak`] = new PassThrough(false);
|
|
65
|
-
NODE_COMPILERS[`${CommonMarkModel.NAMESPACE}.Softbreak`] = new PassThrough(false);
|
|
66
|
-
NODE_COMPILERS[`${CommonMarkModel.NAMESPACE}.Linebreak`] = new PassThrough(false);
|
|
67
|
-
NODE_COMPILERS[`${CommonMarkModel.NAMESPACE}.Link`] = new PassThrough(false);
|
|
68
|
-
NODE_COMPILERS[`${CommonMarkModel.NAMESPACE}.Image`] = new PassThrough(false);
|
|
69
|
-
NODE_COMPILERS[`${CommonMarkModel.NAMESPACE}.List`] = new PassThrough(false);
|
|
70
|
-
NODE_COMPILERS[`${CommonMarkModel.NAMESPACE}.Item`] = new PassThrough(false);
|
|
71
|
-
NODE_COMPILERS[`${CommonMarkModel.NAMESPACE}.Table`] = new PassThrough(false);
|
|
72
|
-
NODE_COMPILERS[`${CommonMarkModel.NAMESPACE}.TableHead`] = new PassThrough(false);
|
|
73
|
-
NODE_COMPILERS[`${CommonMarkModel.NAMESPACE}.TableBody`] = new PassThrough(false);
|
|
74
|
-
NODE_COMPILERS[`${CommonMarkModel.NAMESPACE}.TableRow`] = new PassThrough(false);
|
|
75
|
-
NODE_COMPILERS[`${CommonMarkModel.NAMESPACE}.TableRow`] = new PassThrough(false);
|
|
76
|
-
NODE_COMPILERS[`${CommonMarkModel.NAMESPACE}.HeaderCell`] = new PassThrough(false);
|
|
77
|
-
NODE_COMPILERS[`${CommonMarkModel.NAMESPACE}.TableCell`] = new PassThrough(false);
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Lookup a node compiler
|
|
81
|
-
* @param {string} fqn the Concerto FQN of the node $class
|
|
82
|
-
* @returns {INodeCompiler} the compiler to use for this node
|
|
83
|
-
*/
|
|
84
|
-
export function getCompiler(fqn:string) : INodeCompiler {
|
|
85
|
-
const compiler = NODE_COMPILERS[fqn];
|
|
86
|
-
if(!compiler) {
|
|
87
|
-
throw new Error(`No compiler found for node ${fqn}`);
|
|
88
|
-
}
|
|
89
|
-
return compiler;
|
|
90
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
* you may not use this file except in compliance with the License.
|
|
4
|
-
* You may obtain a copy of the License at
|
|
5
|
-
*
|
|
6
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
*
|
|
8
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
* See the License for the specific language governing permissions and
|
|
12
|
-
* limitations under the License.
|
|
13
|
-
*/
|
|
14
|
-
import { FileWriter } from '@accordproject/concerto-util';
|
|
15
|
-
import { CommonMarkModel,TemplateMarkModel } from '@accordproject/markdown-common';
|
|
16
|
-
|
|
17
|
-
import { ProcessingFunction } from '../TemplateMarkToTypeScriptCompiler';
|
|
18
|
-
import { IOptionalDefinition } from '../model-gen/org.accordproject.templatemark@0.4.0';
|
|
19
|
-
import { AbstractComplexCompiler, getTypeScriptType, makeCiceroMark, writeCloseDataScope, writeCloseGenerateScope, writeCloseNodeScope, writeDebug, writeOpenDataScope, writeOpenGenerateScope, writeOpenNodeScope } from './Common';
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export class Optional extends AbstractComplexCompiler {
|
|
23
|
-
static TYPE = `${TemplateMarkModel.NAMESPACE}.OptionalDefinition`;
|
|
24
|
-
constructor() {
|
|
25
|
-
super(false);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
enter(fw:FileWriter, level:number,templateMarkNode:IOptionalDefinition) {
|
|
29
|
-
writeDebug(fw, level, templateMarkNode);
|
|
30
|
-
writeOpenNodeScope(fw,level);
|
|
31
|
-
writeOpenDataScope(fw,level,templateMarkNode.name, true); // allow pushing undefined onto the stack
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
generate(fw:FileWriter, level:number, templateMarkNode:IOptionalDefinition, doIt:ProcessingFunction) {
|
|
35
|
-
const clone = makeCiceroMark(templateMarkNode) as any;
|
|
36
|
-
delete clone.nodes;
|
|
37
|
-
delete clone.whenSome; // replaced below
|
|
38
|
-
delete clone.whenNone;
|
|
39
|
-
writeOpenGenerateScope(fw, level);
|
|
40
|
-
fw.writeLine(level, `const result = ${JSON.stringify(clone)} as ${getTypeScriptType(templateMarkNode.$class)};`);
|
|
41
|
-
fw.writeLine(level, 'const hasSome:boolean = !(Runtime.peek($data) === null || Runtime.peek($data) === undefined);');
|
|
42
|
-
fw.writeLine(level, '(result as CiceroMark.IOptional).hasSome = hasSome;');
|
|
43
|
-
fw.writeLine(level, 'if(hasSome) {');
|
|
44
|
-
doIt(fw, level+1, {$class: `${CommonMarkModel.NAMESPACE}.Paragraph`, nodes: templateMarkNode.whenSome});
|
|
45
|
-
fw.writeLine(level, '(result as CiceroMark.IOptional).whenSome = $result.nodes[0];');
|
|
46
|
-
fw.writeLine(level, '(result as CiceroMark.IOptional).whenNone = $result.nodes[0];'); // HACK - model needs to be updated
|
|
47
|
-
fw.writeLine(level, 'return result;');
|
|
48
|
-
fw.writeLine(level, '}');
|
|
49
|
-
fw.writeLine(level, 'else {');
|
|
50
|
-
doIt(fw, level+1, {$class: `${CommonMarkModel.NAMESPACE}.Paragraph`, nodes: templateMarkNode.whenNone});
|
|
51
|
-
fw.writeLine(level, '(result as CiceroMark.IOptional).whenNone = $result.nodes[0];');
|
|
52
|
-
fw.writeLine(level, '(result as CiceroMark.IOptional).whenSome = $result.nodes[0];'); // HACK - model needs to be updated
|
|
53
|
-
fw.writeLine(level, 'return result;');
|
|
54
|
-
fw.writeLine(level, '}');
|
|
55
|
-
writeCloseGenerateScope(fw, level);
|
|
56
|
-
delete templateMarkNode.nodes;
|
|
57
|
-
delete (templateMarkNode as any).whenSome; // already handled
|
|
58
|
-
delete (templateMarkNode as any).whenNone;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
exit(fw:FileWriter, level:number) {
|
|
62
|
-
writeCloseDataScope(fw,level);
|
|
63
|
-
writeCloseNodeScope(fw,level);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
* you may not use this file except in compliance with the License.
|
|
4
|
-
* You may obtain a copy of the License at
|
|
5
|
-
*
|
|
6
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
*
|
|
8
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
* See the License for the specific language governing permissions and
|
|
12
|
-
* limitations under the License.
|
|
13
|
-
*/
|
|
14
|
-
import { FileWriter } from '@accordproject/concerto-util';
|
|
15
|
-
import { TemplateMarkModel } from '@accordproject/markdown-common';
|
|
16
|
-
import { IVariable } from '../model-gen/org.accordproject.ciceromark@0.6.0';
|
|
17
|
-
import { IVariableDefinition } from '../model-gen/org.accordproject.templatemark@0.4.0';
|
|
18
|
-
import { AbstractComplexCompiler, getTypeScriptType, makeCiceroMark, writeCloseDataScope, writeCloseGenerateScope, writeOpenDataScope, writeOpenGenerateScope } from './Common';
|
|
19
|
-
|
|
20
|
-
export class Variable extends AbstractComplexCompiler {
|
|
21
|
-
static TYPE = `${TemplateMarkModel.NAMESPACE}.VariableDefinition`;
|
|
22
|
-
constructor() {
|
|
23
|
-
super(true);
|
|
24
|
-
}
|
|
25
|
-
generate(fw:FileWriter, level:number, templateMarkNode:IVariableDefinition) {
|
|
26
|
-
const clone = makeCiceroMark(templateMarkNode) as IVariable;
|
|
27
|
-
writeOpenGenerateScope(fw,level);
|
|
28
|
-
if(templateMarkNode.name !== 'this') {
|
|
29
|
-
writeOpenDataScope(fw,level,templateMarkNode.name);
|
|
30
|
-
}
|
|
31
|
-
fw.writeLine(level, 'const text = JSON.stringify(Runtime.peek($data)) as string;');
|
|
32
|
-
if(templateMarkNode.name !== 'this') {
|
|
33
|
-
writeCloseDataScope(fw,level);
|
|
34
|
-
}
|
|
35
|
-
fw.writeLine(level, `const variable:any = ${JSON.stringify(clone)};`);
|
|
36
|
-
fw.writeLine(level, 'variable.value = text;');
|
|
37
|
-
fw.writeLine(level, `return variable as ${getTypeScriptType(clone.$class)};`);
|
|
38
|
-
writeCloseGenerateScope(fw,level);
|
|
39
|
-
}
|
|
40
|
-
}
|