bit2 0.1.7 → 0.1.8
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 +73 -3
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,5 +1,75 @@
|
|
|
1
|
-
|
|
1
|
+
## BIT2
|
|
2
2
|
A bidirectional template engine that supports modifying templates by modifying output directly.
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
|
|
5
|
+
## Language Syntax
|
|
6
|
+
|
|
7
|
+
keywords: `var`, `if`, `endif`, `elseif`, `for`, `in`, `endfor`, `separator`, `front`, `rear`.
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
Fragment := Literal | Directive | Fragment Fragment
|
|
11
|
+
Directive := «var Name = Expr» | «Name = Expr» | «Expr»
|
|
12
|
+
| «if Expr» Fragment ElseBranch «endif»
|
|
13
|
+
| «for Name in Expr ForLitList» Fragment «endfor»
|
|
14
|
+
ElseBranch := «elseif Expr» Fragment ElseBranch
|
|
15
|
+
| «else» Fragment
|
|
16
|
+
ForLit := separator string | front string | rear string
|
|
17
|
+
Expr := basic arithmetic, relational, and boolean expressions
|
|
18
|
+
| Expr . Name | Value
|
|
19
|
+
Name := identifiers
|
|
20
|
+
Value := record, list, tuple, string, integer, and boolean values
|
|
21
|
+
Literal := any char sequence that does not contain «
|
|
22
|
+
```
|
|
23
|
+
## Usage
|
|
24
|
+
Please install `LiveT` plugin in VSCode, and use it.
|
|
25
|
+
|
|
26
|
+
1. load `LiveT` plugin.
|
|
27
|
+
2. write template in text editor using bit2 syntax.
|
|
28
|
+
2. click `forward` button to evaluates to text.
|
|
29
|
+
3. update output text through deletion, insertion, replacement (select text and right click, a popup shows a list of actions).
|
|
30
|
+
4. click `backward` button to reflect changes back to template
|
|
31
|
+
|
|
32
|
+
## Example
|
|
33
|
+
|
|
34
|
+
### 1. Assignment
|
|
35
|
+
```
|
|
36
|
+
«var no = 0»
|
|
37
|
+
Before: «no»
|
|
38
|
+
«no = no + 1»
|
|
39
|
+
After: «no»
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### 2. Branch
|
|
43
|
+
```
|
|
44
|
+
«var age=19»
|
|
45
|
+
«var count=1»
|
|
46
|
+
«if age>=18»
|
|
47
|
+
Wow! An adult! «count»
|
|
48
|
+
«else»
|
|
49
|
+
Hi! A little boy! «count»
|
|
50
|
+
«endif»
|
|
51
|
+
«count»
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 3. Forloop
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
«var lst=[{head:"Modeling", text:"UML"},{head:"Programming", text:"Java"}]»
|
|
58
|
+
«for p in lst»
|
|
59
|
+
<h1>«p.head»</h1>
|
|
60
|
+
«endfor»
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 4. Mixed
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
«var paragraphs =[{head:"Hello", text:"Hello!"}, {head:"Farewell", text:"Good Bye!"}] »
|
|
67
|
+
<html>
|
|
68
|
+
<body>«var no = 0»«for p in paragraphs»
|
|
69
|
+
«if p.head != ""»«no = no + 1»<h1>«no».«p.head»</h1>«endif»
|
|
70
|
+
<p>
|
|
71
|
+
«p.text»
|
|
72
|
+
</p>«endfor»
|
|
73
|
+
</body>
|
|
74
|
+
</html>
|
|
75
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bit2",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"main": "dist/bit2.js",
|
|
5
5
|
"types": "dist/bit2.d.ts",
|
|
6
6
|
"dependencies": {
|
|
@@ -57,7 +57,8 @@
|
|
|
57
57
|
"example.test": "node dist/test/examples/Test.test.js",
|
|
58
58
|
"example.simple": "node dist/test/examples/Test.simple.test.js",
|
|
59
59
|
"runPerformance": "node dist/test/performance/runPerformance.js",
|
|
60
|
-
"runPerformance2": "node dist/test/performance/run.js"
|
|
60
|
+
"runPerformance2": "node dist/test/performance/run.js",
|
|
61
|
+
"runCaseStudy": "node dist/test/casestudy/run.js"
|
|
61
62
|
},
|
|
62
63
|
"files": [
|
|
63
64
|
"dist/bit2.js",
|