Commit f037dbb
authored
Engine: Delegate context-aware expressions to overridable engine methods (#1421)
This pull request moves expression handling logic from the compiler into
overridable engine methods, making `Herb::Engine` an easier drop-in
replacement for `Erubi::Engine`.
Previously, the compiler bypassed the engine's `add_expression` method
in two cases:
1. **Block expressions** (`<%= link_to do %>...<% end %>`), the compiler
called `add_expression_block` which dispatched directly to
`add_expression_block_result`, skipping any subclass override of
`add_expression`.
2. **Context-aware expressions** (inside `<script>`, `<style>`, or
attribute values), the compiler's `add_context_aware_expression` wrote
directly to `@engine.src`, bypassing the engine entirely (see #1419)
This meant subclasses that overrode `add_expression` (the Erubi pattern
used by ActionView) would not have their override apply to blocks or
context-aware expressions, leading to incorrect compiled output.
So the idea of this pull request is to move the logic from the compiler
into overridable engine methods so that subclasses (like ReActionView)
get correct behavior by only overriding `add_expression`. The compiler
becomes a thin dispatcher that routes tokens to the engine and no longer
manipulates `@engine.src` directly.
Resolves #1419
Related marcoroth/reactionview#78
Related marcoroth/reactionview#80
Related marcoroth/reactionview#831 parent 41ca2f4 commit f037dbb
File tree
4 files changed
+46
-43
lines changed- lib/herb
- engine
- sig/herb
- engine
4 files changed
+46
-43
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
58 | 61 | | |
59 | 62 | | |
60 | 63 | | |
| |||
244 | 247 | | |
245 | 248 | | |
246 | 249 | | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
247 | 268 | | |
248 | 269 | | |
249 | 270 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | 13 | | |
17 | 14 | | |
18 | 15 | | |
| |||
28 | 25 | | |
29 | 26 | | |
30 | 27 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
41 | 33 | | |
42 | | - | |
43 | 34 | | |
44 | 35 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
| 36 | + | |
| 37 | + | |
51 | 38 | | |
52 | 39 | | |
53 | 40 | | |
| |||
342 | 329 | | |
343 | 330 | | |
344 | 331 | | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | 332 | | |
367 | 333 | | |
368 | 334 | | |
| |||
503 | 469 | | |
504 | 470 | | |
505 | 471 | | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
506 | 482 | | |
507 | 483 | | |
508 | 484 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments