You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The rendering mode of Twig.js internally is determined by the `allow_async` argument that can be passed into `Twig.expression.parse`, `Twig.logic.parse`, `Twig.parse` and `Twig.Template.render`. Detecting if at any point code runs asynchronously is explained in [detecting asynchronous behaviour](#detecting-asynchronous-behaviour).
119
+
The rendering mode of Twig.js internally is determined by the `allowAsync` argument that can be passed into `Twig.expression.parse`, `Twig.logic.parse`, `Twig.parse` and `Twig.Template.render`. Detecting if at any point code runs asynchronously is explained in [detecting asynchronous behaviour](#detecting-asynchronous-behaviour).
120
120
121
121
For the end user switching between synchronous and asynchronous is as simple as using a different method on the template instance.
122
122
@@ -157,10 +157,10 @@ var template = twig({
157
157
158
158
The pattern used to detect asynchronous behaviour is the same everywhere it is used and follows a simple pattern.
159
159
160
-
1. Set a variable `is_async = true`
160
+
1. Set a variable `isAsync = true`
161
161
2. Run the promise chain that might contain some asynchronous behaviour.
162
-
3. As the last method in the promise chain set `is_async = false`
163
-
4. Underneath the promise chain test whether `is_async` is `true`
162
+
3. As the last method in the promise chain set `isAsync = false`
163
+
4. Underneath the promise chain test whether `isAsync` is `true`
164
164
165
165
This pattern works because the last method in the chain will be executed in the next run of the eventloop (`setTimeout`/`setImmediate`).
166
166
@@ -169,7 +169,7 @@ This pattern works because the last method in the chain will be executed in the
169
169
**Synchronous promises only**
170
170
171
171
```javascript
172
-
varis_async=true;
172
+
varisAsync=true;
173
173
174
174
Twig.Promise.resolve()
175
175
.then(function() {
@@ -178,10 +178,10 @@ Twig.Promise.resolve()
178
178
return'hello world';
179
179
})
180
180
.then(function() {
181
-
is_async=false;
181
+
isAsync=false;
182
182
});
183
183
184
-
if (is_async)
184
+
if (isAsync)
185
185
console.log('method ran asynchronous');
186
186
187
187
console.log('method ran synchronous');
@@ -195,18 +195,18 @@ console.log('method ran synchronous');
195
195
**Mixed promises**
196
196
197
197
```javascript
198
-
varis_async=true;
198
+
varisAsync=true;
199
199
200
200
Twig.Promise.resolve()
201
201
.then(function() {
202
202
// We run our work in here such to allow for asynchronous work
0 commit comments