herb 0.9.0-arm-linux-gnu → 0.9.2-arm-linux-gnu
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.
- checksums.yaml +4 -4
- data/config.yml +156 -0
- data/ext/herb/error_helpers.c +168 -0
- data/ext/herb/extension.c +4 -0
- data/ext/herb/extension_helpers.c +1 -0
- data/ext/herb/nodes.c +110 -0
- data/lib/herb/3.0/herb.so +0 -0
- data/lib/herb/3.1/herb.so +0 -0
- data/lib/herb/3.2/herb.so +0 -0
- data/lib/herb/3.3/herb.so +0 -0
- data/lib/herb/3.4/herb.so +0 -0
- data/lib/herb/4.0/herb.so +0 -0
- data/lib/herb/ast/nodes.rb +393 -17
- data/lib/herb/engine/compiler.rb +17 -41
- data/lib/herb/engine.rb +76 -26
- data/lib/herb/errors.rb +245 -0
- data/lib/herb/parser_options.rb +6 -1
- data/lib/herb/prism_inspect.rb +5 -1
- data/lib/herb/version.rb +1 -1
- data/lib/herb/visitor.rb +10 -0
- data/sig/herb/ast/nodes.rbs +132 -0
- data/sig/herb/engine/compiler.rbs +4 -2
- data/sig/herb/engine.rbs +8 -0
- data/sig/herb/errors.rbs +114 -0
- data/sig/herb/parser_options.rbs +4 -0
- data/sig/herb/visitor.rbs +6 -0
- data/sig/rubyvm.rbs +5 -0
- data/sig/serialized_ast_errors.rbs +28 -0
- data/sig/serialized_ast_nodes.rbs +31 -0
- data/src/analyze/action_view/attribute_extraction_helpers.c +23 -1
- data/src/analyze/action_view/content_tag.c +19 -11
- data/src/analyze/action_view/javascript_include_tag.c +92 -0
- data/src/analyze/action_view/javascript_tag.c +55 -0
- data/src/analyze/action_view/link_to.c +25 -1
- data/src/analyze/action_view/registry.c +29 -2
- data/src/analyze/action_view/tag.c +14 -8
- data/src/analyze/action_view/tag_helper_node_builders.c +16 -3
- data/src/analyze/action_view/tag_helpers.c +332 -12
- data/src/analyze/analyze.c +3 -0
- data/src/analyze/prism_annotate.c +4 -2
- data/src/analyze/render_nodes.c +761 -0
- data/src/analyze/transform.c +7 -0
- data/src/ast_nodes.c +97 -0
- data/src/ast_pretty_print.c +74 -0
- data/src/errors.c +379 -0
- data/src/html_util.c +50 -0
- data/src/include/analyze/action_view/tag_helper_handler.h +2 -0
- data/src/include/analyze/render_nodes.h +11 -0
- data/src/include/ast_nodes.h +37 -0
- data/src/include/errors.h +58 -0
- data/src/include/html_util.h +1 -0
- data/src/include/parser.h +1 -0
- data/src/include/version.h +1 -1
- data/src/parser.c +1 -0
- data/src/parser_match_tags.c +20 -0
- data/src/util/hb_arena.c +3 -7
- data/src/visitor.c +20 -0
- data/templates/lib/herb/ast/nodes.rb.erb +8 -2
- data/templates/rust/src/ast/nodes.rs.erb +1 -1
- data/templates/rust/src/nodes.rs.erb +1 -1
- metadata +6 -1
data/src/html_util.c
CHANGED
|
@@ -27,6 +27,46 @@ static hb_string_T void_tags[] = HB_STRING_LIST(
|
|
|
27
27
|
"wbr"
|
|
28
28
|
);
|
|
29
29
|
|
|
30
|
+
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes
|
|
31
|
+
static hb_string_T boolean_attributes[] = HB_STRING_LIST(
|
|
32
|
+
"allowfullscreen",
|
|
33
|
+
"async",
|
|
34
|
+
"autofocus",
|
|
35
|
+
"autoplay",
|
|
36
|
+
"checked",
|
|
37
|
+
"compact",
|
|
38
|
+
"controls",
|
|
39
|
+
"declare",
|
|
40
|
+
"default",
|
|
41
|
+
"defer",
|
|
42
|
+
"disabled",
|
|
43
|
+
"formnovalidate",
|
|
44
|
+
"hidden",
|
|
45
|
+
"inert",
|
|
46
|
+
"ismap",
|
|
47
|
+
"itemscope",
|
|
48
|
+
"loop",
|
|
49
|
+
"multiple",
|
|
50
|
+
"muted",
|
|
51
|
+
"nomodule",
|
|
52
|
+
"nohref",
|
|
53
|
+
"noresize",
|
|
54
|
+
"noshade",
|
|
55
|
+
"novalidate",
|
|
56
|
+
"nowrap",
|
|
57
|
+
"open",
|
|
58
|
+
"playsinline",
|
|
59
|
+
"readonly",
|
|
60
|
+
"required",
|
|
61
|
+
"reversed",
|
|
62
|
+
"scoped",
|
|
63
|
+
"seamless",
|
|
64
|
+
"selected",
|
|
65
|
+
"sortable",
|
|
66
|
+
"truespeed",
|
|
67
|
+
"typemustmatch"
|
|
68
|
+
);
|
|
69
|
+
|
|
30
70
|
// https://html.spec.whatwg.org/multipage/syntax.html#optional-tags
|
|
31
71
|
static hb_string_T optional_end_tags[] = HB_STRING_LIST(
|
|
32
72
|
"li",
|
|
@@ -112,6 +152,16 @@ bool is_void_element(hb_string_T tag_name) {
|
|
|
112
152
|
return false;
|
|
113
153
|
}
|
|
114
154
|
|
|
155
|
+
bool is_boolean_attribute(hb_string_T attribute_name) {
|
|
156
|
+
if (hb_string_is_empty(attribute_name)) { return false; }
|
|
157
|
+
|
|
158
|
+
for (size_t i = 0; i < sizeof(boolean_attributes) / sizeof(boolean_attributes[0]); i++) {
|
|
159
|
+
if (hb_string_equals_case_insensitive(attribute_name, boolean_attributes[i])) { return true; }
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
|
|
115
165
|
bool has_optional_end_tag(hb_string_T tag_name) {
|
|
116
166
|
if (hb_string_is_empty(tag_name)) { return false; }
|
|
117
167
|
|
data/src/include/ast_nodes.h
CHANGED
|
@@ -57,6 +57,8 @@ typedef enum {
|
|
|
57
57
|
AST_ERB_ENSURE_NODE,
|
|
58
58
|
AST_ERB_BEGIN_NODE,
|
|
59
59
|
AST_ERB_UNLESS_NODE,
|
|
60
|
+
AST_RUBY_RENDER_LOCAL_NODE,
|
|
61
|
+
AST_ERB_RENDER_NODE,
|
|
60
62
|
AST_ERB_YIELD_NODE,
|
|
61
63
|
AST_ERB_IN_NODE,
|
|
62
64
|
} ast_node_type_T;
|
|
@@ -368,6 +370,39 @@ typedef struct AST_ERB_UNLESS_NODE_STRUCT {
|
|
|
368
370
|
struct AST_ERB_END_NODE_STRUCT* end_node;
|
|
369
371
|
} AST_ERB_UNLESS_NODE_T;
|
|
370
372
|
|
|
373
|
+
typedef struct AST_RUBY_RENDER_LOCAL_NODE_STRUCT {
|
|
374
|
+
AST_NODE_T base;
|
|
375
|
+
token_T* name;
|
|
376
|
+
struct AST_RUBY_LITERAL_NODE_STRUCT* value;
|
|
377
|
+
} AST_RUBY_RENDER_LOCAL_NODE_T;
|
|
378
|
+
|
|
379
|
+
typedef struct AST_ERB_RENDER_NODE_STRUCT {
|
|
380
|
+
AST_NODE_T base;
|
|
381
|
+
token_T* tag_opening;
|
|
382
|
+
token_T* content;
|
|
383
|
+
token_T* tag_closing;
|
|
384
|
+
analyzed_ruby_T* analyzed_ruby;
|
|
385
|
+
herb_prism_node_T prism_node;
|
|
386
|
+
token_T* partial;
|
|
387
|
+
token_T* template_path;
|
|
388
|
+
token_T* layout;
|
|
389
|
+
token_T* file;
|
|
390
|
+
token_T* inline_template;
|
|
391
|
+
token_T* body;
|
|
392
|
+
token_T* plain;
|
|
393
|
+
token_T* html;
|
|
394
|
+
token_T* renderable;
|
|
395
|
+
token_T* collection;
|
|
396
|
+
token_T* object;
|
|
397
|
+
token_T* as_name;
|
|
398
|
+
token_T* spacer_template;
|
|
399
|
+
token_T* formats;
|
|
400
|
+
token_T* variants;
|
|
401
|
+
token_T* handlers;
|
|
402
|
+
token_T* content_type;
|
|
403
|
+
hb_array_T* locals;
|
|
404
|
+
} AST_ERB_RENDER_NODE_T;
|
|
405
|
+
|
|
371
406
|
typedef struct AST_ERB_YIELD_NODE_STRUCT {
|
|
372
407
|
AST_NODE_T base;
|
|
373
408
|
token_T* tag_opening;
|
|
@@ -420,6 +455,8 @@ AST_ERB_RESCUE_NODE_T* ast_erb_rescue_node_init(token_T* tag_opening, token_T* c
|
|
|
420
455
|
AST_ERB_ENSURE_NODE_T* ast_erb_ensure_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, hb_array_T* statements, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
|
|
421
456
|
AST_ERB_BEGIN_NODE_T* ast_erb_begin_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, herb_prism_node_T prism_node, hb_array_T* statements, struct AST_ERB_RESCUE_NODE_STRUCT* rescue_clause, struct AST_ERB_ELSE_NODE_STRUCT* else_clause, struct AST_ERB_ENSURE_NODE_STRUCT* ensure_clause, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
|
|
422
457
|
AST_ERB_UNLESS_NODE_T* ast_erb_unless_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, location_T* then_keyword, herb_prism_node_T prism_node, hb_array_T* statements, struct AST_ERB_ELSE_NODE_STRUCT* else_clause, struct AST_ERB_END_NODE_STRUCT* end_node, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
|
|
458
|
+
AST_RUBY_RENDER_LOCAL_NODE_T* ast_ruby_render_local_node_init(token_T* name, struct AST_RUBY_LITERAL_NODE_STRUCT* value, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
|
|
459
|
+
AST_ERB_RENDER_NODE_T* ast_erb_render_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, analyzed_ruby_T* analyzed_ruby, herb_prism_node_T prism_node, token_T* partial, token_T* template_path, token_T* layout, token_T* file, token_T* inline_template, token_T* body, token_T* plain, token_T* html, token_T* renderable, token_T* collection, token_T* object, token_T* as_name, token_T* spacer_template, token_T* formats, token_T* variants, token_T* handlers, token_T* content_type, hb_array_T* locals, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
|
|
423
460
|
AST_ERB_YIELD_NODE_T* ast_erb_yield_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
|
|
424
461
|
AST_ERB_IN_NODE_T* ast_erb_in_node_init(token_T* tag_opening, token_T* content, token_T* tag_closing, location_T* then_keyword, hb_array_T* statements, position_T start_position, position_T end_position, hb_array_T* errors, hb_allocator_T* allocator);
|
|
425
462
|
|
data/src/include/errors.h
CHANGED
|
@@ -37,6 +37,13 @@ typedef enum {
|
|
|
37
37
|
UNCLOSED_ERB_TAG_ERROR,
|
|
38
38
|
STRAY_ERB_CLOSING_TAG_ERROR,
|
|
39
39
|
NESTED_ERB_TAG_ERROR,
|
|
40
|
+
RENDER_AMBIGUOUS_LOCALS_ERROR,
|
|
41
|
+
RENDER_MISSING_LOCALS_ERROR,
|
|
42
|
+
RENDER_NO_ARGUMENTS_ERROR,
|
|
43
|
+
RENDER_CONFLICTING_PARTIAL_ERROR,
|
|
44
|
+
RENDER_INVALID_AS_OPTION_ERROR,
|
|
45
|
+
RENDER_OBJECT_AND_COLLECTION_ERROR,
|
|
46
|
+
RENDER_LAYOUT_WITHOUT_BLOCK_ERROR,
|
|
40
47
|
} error_type_T;
|
|
41
48
|
|
|
42
49
|
typedef struct ERROR_STRUCT {
|
|
@@ -179,6 +186,43 @@ typedef struct {
|
|
|
179
186
|
size_t nested_tag_column;
|
|
180
187
|
} NESTED_ERB_TAG_ERROR_T;
|
|
181
188
|
|
|
189
|
+
typedef struct {
|
|
190
|
+
ERROR_T base;
|
|
191
|
+
hb_string_T partial;
|
|
192
|
+
} RENDER_AMBIGUOUS_LOCALS_ERROR_T;
|
|
193
|
+
|
|
194
|
+
typedef struct {
|
|
195
|
+
ERROR_T base;
|
|
196
|
+
hb_string_T partial;
|
|
197
|
+
hb_string_T keywords;
|
|
198
|
+
} RENDER_MISSING_LOCALS_ERROR_T;
|
|
199
|
+
|
|
200
|
+
typedef struct {
|
|
201
|
+
ERROR_T base;
|
|
202
|
+
/* no additional fields */
|
|
203
|
+
} RENDER_NO_ARGUMENTS_ERROR_T;
|
|
204
|
+
|
|
205
|
+
typedef struct {
|
|
206
|
+
ERROR_T base;
|
|
207
|
+
hb_string_T positional_partial;
|
|
208
|
+
hb_string_T keyword_partial;
|
|
209
|
+
} RENDER_CONFLICTING_PARTIAL_ERROR_T;
|
|
210
|
+
|
|
211
|
+
typedef struct {
|
|
212
|
+
ERROR_T base;
|
|
213
|
+
hb_string_T as_value;
|
|
214
|
+
} RENDER_INVALID_AS_OPTION_ERROR_T;
|
|
215
|
+
|
|
216
|
+
typedef struct {
|
|
217
|
+
ERROR_T base;
|
|
218
|
+
/* no additional fields */
|
|
219
|
+
} RENDER_OBJECT_AND_COLLECTION_ERROR_T;
|
|
220
|
+
|
|
221
|
+
typedef struct {
|
|
222
|
+
ERROR_T base;
|
|
223
|
+
hb_string_T layout;
|
|
224
|
+
} RENDER_LAYOUT_WITHOUT_BLOCK_ERROR_T;
|
|
225
|
+
|
|
182
226
|
UNEXPECTED_ERROR_T* unexpected_error_init(hb_string_T description, hb_string_T expected, hb_string_T found, position_T start, position_T end, hb_allocator_T* allocator);
|
|
183
227
|
void append_unexpected_error(hb_string_T description, hb_string_T expected, hb_string_T found, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
|
|
184
228
|
UNEXPECTED_TOKEN_ERROR_T* unexpected_token_error_init(token_type_T expected_type, token_T* found, position_T start, position_T end, hb_allocator_T* allocator);
|
|
@@ -225,6 +269,20 @@ STRAY_ERB_CLOSING_TAG_ERROR_T* stray_erb_closing_tag_error_init(position_T start
|
|
|
225
269
|
void append_stray_erb_closing_tag_error(position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
|
|
226
270
|
NESTED_ERB_TAG_ERROR_T* nested_erb_tag_error_init(token_T* opening_tag, size_t nested_tag_line, size_t nested_tag_column, position_T start, position_T end, hb_allocator_T* allocator);
|
|
227
271
|
void append_nested_erb_tag_error(token_T* opening_tag, size_t nested_tag_line, size_t nested_tag_column, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
|
|
272
|
+
RENDER_AMBIGUOUS_LOCALS_ERROR_T* render_ambiguous_locals_error_init(hb_string_T partial, position_T start, position_T end, hb_allocator_T* allocator);
|
|
273
|
+
void append_render_ambiguous_locals_error(hb_string_T partial, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
|
|
274
|
+
RENDER_MISSING_LOCALS_ERROR_T* render_missing_locals_error_init(hb_string_T partial, hb_string_T keywords, position_T start, position_T end, hb_allocator_T* allocator);
|
|
275
|
+
void append_render_missing_locals_error(hb_string_T partial, hb_string_T keywords, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
|
|
276
|
+
RENDER_NO_ARGUMENTS_ERROR_T* render_no_arguments_error_init(position_T start, position_T end, hb_allocator_T* allocator);
|
|
277
|
+
void append_render_no_arguments_error(position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
|
|
278
|
+
RENDER_CONFLICTING_PARTIAL_ERROR_T* render_conflicting_partial_error_init(hb_string_T positional_partial, hb_string_T keyword_partial, position_T start, position_T end, hb_allocator_T* allocator);
|
|
279
|
+
void append_render_conflicting_partial_error(hb_string_T positional_partial, hb_string_T keyword_partial, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
|
|
280
|
+
RENDER_INVALID_AS_OPTION_ERROR_T* render_invalid_as_option_error_init(hb_string_T as_value, position_T start, position_T end, hb_allocator_T* allocator);
|
|
281
|
+
void append_render_invalid_as_option_error(hb_string_T as_value, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
|
|
282
|
+
RENDER_OBJECT_AND_COLLECTION_ERROR_T* render_object_and_collection_error_init(position_T start, position_T end, hb_allocator_T* allocator);
|
|
283
|
+
void append_render_object_and_collection_error(position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
|
|
284
|
+
RENDER_LAYOUT_WITHOUT_BLOCK_ERROR_T* render_layout_without_block_error_init(hb_string_T layout, position_T start, position_T end, hb_allocator_T* allocator);
|
|
285
|
+
void append_render_layout_without_block_error(hb_string_T layout, position_T start, position_T end, hb_allocator_T* allocator, hb_array_T* errors);
|
|
228
286
|
|
|
229
287
|
void error_init(ERROR_T* error, error_type_T type, position_T start, position_T end);
|
|
230
288
|
|
data/src/include/html_util.h
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
struct hb_allocator;
|
|
8
8
|
|
|
9
9
|
bool is_void_element(hb_string_T tag_name);
|
|
10
|
+
bool is_boolean_attribute(hb_string_T attribute_name);
|
|
10
11
|
bool has_optional_end_tag(hb_string_T tag_name);
|
|
11
12
|
bool should_implicitly_close(hb_string_T open_tag_name, hb_string_T next_tag_name);
|
|
12
13
|
bool parent_closes_element(hb_string_T open_tag_name, hb_string_T parent_close_tag_name);
|
data/src/include/parser.h
CHANGED
data/src/include/version.h
CHANGED
data/src/parser.c
CHANGED
|
@@ -37,6 +37,7 @@ const parser_options_T HERB_DEFAULT_PARSER_OPTIONS = { .track_whitespace = false
|
|
|
37
37
|
.analyze = true,
|
|
38
38
|
.strict = true,
|
|
39
39
|
.action_view_helpers = false,
|
|
40
|
+
.render_nodes = false,
|
|
40
41
|
.prism_nodes_deep = false,
|
|
41
42
|
.prism_nodes = false,
|
|
42
43
|
.prism_program = false };
|
data/src/parser_match_tags.c
CHANGED
|
@@ -360,6 +360,26 @@ bool match_tags_visitor(const AST_NODE_T* node, void* data) {
|
|
|
360
360
|
|
|
361
361
|
|
|
362
362
|
|
|
363
|
+
case AST_RUBY_RENDER_LOCAL_NODE: {
|
|
364
|
+
const AST_RUBY_RENDER_LOCAL_NODE_T* ruby_render_local_node = (const AST_RUBY_RENDER_LOCAL_NODE_T*) node;
|
|
365
|
+
|
|
366
|
+
if (ruby_render_local_node->value != NULL) {
|
|
367
|
+
herb_visit_node((AST_NODE_T*) ruby_render_local_node->value, match_tags_visitor, context);
|
|
368
|
+
}
|
|
369
|
+
} break;
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
case AST_ERB_RENDER_NODE: {
|
|
374
|
+
const AST_ERB_RENDER_NODE_T* erb_render_node = (const AST_ERB_RENDER_NODE_T*) node;
|
|
375
|
+
|
|
376
|
+
if (erb_render_node->locals != NULL) {
|
|
377
|
+
match_tags_in_node_array(erb_render_node->locals, context->errors, context->options, context->allocator);
|
|
378
|
+
}
|
|
379
|
+
} break;
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
|
|
363
383
|
|
|
364
384
|
|
|
365
385
|
case AST_ERB_IN_NODE: {
|
data/src/util/hb_arena.c
CHANGED
|
@@ -70,16 +70,12 @@ static bool hb_arena_append_page(hb_arena_T* allocator, size_t page_size) {
|
|
|
70
70
|
page->position = 0;
|
|
71
71
|
|
|
72
72
|
if (allocator->head == NULL) {
|
|
73
|
+
assert(allocator->tail == NULL);
|
|
74
|
+
|
|
73
75
|
allocator->head = page;
|
|
74
76
|
allocator->tail = page;
|
|
75
77
|
} else {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
while (last->next != NULL) {
|
|
79
|
-
last = last->next;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
last->next = page;
|
|
78
|
+
allocator->tail->next = page;
|
|
83
79
|
allocator->tail = page;
|
|
84
80
|
}
|
|
85
81
|
|
data/src/visitor.c
CHANGED
|
@@ -421,6 +421,26 @@ void herb_visit_child_nodes(const AST_NODE_T *node, bool (*visitor)(const AST_NO
|
|
|
421
421
|
|
|
422
422
|
} break;
|
|
423
423
|
|
|
424
|
+
case AST_RUBY_RENDER_LOCAL_NODE: {
|
|
425
|
+
const AST_RUBY_RENDER_LOCAL_NODE_T* ruby_render_local_node = ((const AST_RUBY_RENDER_LOCAL_NODE_T *) node);
|
|
426
|
+
|
|
427
|
+
if (ruby_render_local_node->value != NULL) {
|
|
428
|
+
herb_visit_node((AST_NODE_T *) ruby_render_local_node->value, visitor, data);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
} break;
|
|
432
|
+
|
|
433
|
+
case AST_ERB_RENDER_NODE: {
|
|
434
|
+
const AST_ERB_RENDER_NODE_T* erb_render_node = ((const AST_ERB_RENDER_NODE_T *) node);
|
|
435
|
+
|
|
436
|
+
if (erb_render_node->locals != NULL) {
|
|
437
|
+
for (size_t index = 0; index < hb_array_size(erb_render_node->locals); index++) {
|
|
438
|
+
herb_visit_node(hb_array_get(erb_render_node->locals, index), visitor, data);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
} break;
|
|
443
|
+
|
|
424
444
|
case AST_ERB_IN_NODE: {
|
|
425
445
|
const AST_ERB_IN_NODE_T* erb_in_node = ((const AST_ERB_IN_NODE_T *) node);
|
|
426
446
|
|
|
@@ -22,7 +22,7 @@ module Herb
|
|
|
22
22
|
super(type, location, errors)
|
|
23
23
|
<%- node.fields.each do |field| -%>
|
|
24
24
|
<%- if field.is_a?(Herb::Template::StringField) -%>
|
|
25
|
-
@<%= field.name %> = <%= field.name
|
|
25
|
+
@<%= field.name %> = <%= field.name %>&.force_encoding("utf-8")
|
|
26
26
|
<%- else -%>
|
|
27
27
|
@<%= field.name %> = <%= field.name %>
|
|
28
28
|
<%- end -%>
|
|
@@ -37,7 +37,13 @@ module Herb
|
|
|
37
37
|
return nil unless prism_node
|
|
38
38
|
return nil unless source
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
begin
|
|
41
|
+
require "prism"
|
|
42
|
+
rescue LoadError
|
|
43
|
+
warn "The 'prism' gem is required to deserialize Prism nodes. Add it to your Gemfile or install it with: gem install prism"
|
|
44
|
+
return nil
|
|
45
|
+
end
|
|
46
|
+
|
|
41
47
|
Prism.load(source, prism_node).value
|
|
42
48
|
end
|
|
43
49
|
|
|
@@ -171,7 +171,7 @@ unsafe fn convert_node(node_pointer: *const c_void) -> Option<AnyNode> {
|
|
|
171
171
|
|
|
172
172
|
match node_type {
|
|
173
173
|
<%- nodes.each do |node| -%>
|
|
174
|
-
<%= node.type %> => convert_<%= node.human %>(node_pointer).map(AnyNode::<%= node.name %>),
|
|
174
|
+
<%= node.type %> => convert_<%= node.human %>(node_pointer).map(|n| AnyNode::<%= node.name %>(Box::new(n))),
|
|
175
175
|
<%- end -%>
|
|
176
176
|
_ => {
|
|
177
177
|
eprintln!("Warning: Unknown node type {}", node_type);
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: herb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.2
|
|
5
5
|
platform: arm-linux-gnu
|
|
6
6
|
authors:
|
|
7
7
|
- Marco Roth
|
|
@@ -110,11 +110,14 @@ files:
|
|
|
110
110
|
- sig/herb/visitor.rbs
|
|
111
111
|
- sig/herb/warnings.rbs
|
|
112
112
|
- sig/herb_c_extension.rbs
|
|
113
|
+
- sig/rubyvm.rbs
|
|
113
114
|
- sig/serialized.rbs
|
|
114
115
|
- sig/serialized_ast_errors.rbs
|
|
115
116
|
- sig/serialized_ast_nodes.rbs
|
|
116
117
|
- src/analyze/action_view/attribute_extraction_helpers.c
|
|
117
118
|
- src/analyze/action_view/content_tag.c
|
|
119
|
+
- src/analyze/action_view/javascript_include_tag.c
|
|
120
|
+
- src/analyze/action_view/javascript_tag.c
|
|
118
121
|
- src/analyze/action_view/link_to.c
|
|
119
122
|
- src/analyze/action_view/registry.c
|
|
120
123
|
- src/analyze/action_view/tag.c
|
|
@@ -132,6 +135,7 @@ files:
|
|
|
132
135
|
- src/analyze/missing_end.c
|
|
133
136
|
- src/analyze/parse_errors.c
|
|
134
137
|
- src/analyze/prism_annotate.c
|
|
138
|
+
- src/analyze/render_nodes.c
|
|
135
139
|
- src/analyze/transform.c
|
|
136
140
|
- src/ast_node.c
|
|
137
141
|
- src/ast_nodes.c
|
|
@@ -153,6 +157,7 @@ files:
|
|
|
153
157
|
- src/include/analyze/helpers.h
|
|
154
158
|
- src/include/analyze/invalid_structures.h
|
|
155
159
|
- src/include/analyze/prism_annotate.h
|
|
160
|
+
- src/include/analyze/render_nodes.h
|
|
156
161
|
- src/include/ast_node.h
|
|
157
162
|
- src/include/ast_nodes.h
|
|
158
163
|
- src/include/ast_pretty_print.h
|