1
1
#include "liquid.h"
2
2
#include "vm_assembler.h"
3
3
#include "block.h"
4
+ #include "tokenizer.h"
5
+ #include "variable.h"
4
6
5
7
static ID id_parse ;
6
8
@@ -29,10 +31,32 @@ static VALUE tag_compile(VALUE self, VALUE block_body_obj)
29
31
{
30
32
block_body_t * body ;
31
33
BlockBody_Get_Struct (block_body_obj , body );
34
+ block_body_ensure_intermediate (body );
32
35
vm_assembler_add_write_node_from_ruby (body -> as .intermediate .code , self );
33
36
return Qnil ;
34
37
}
35
38
39
+ static VALUE echo_class_compile (VALUE klass , VALUE tag_name , VALUE markup ,
40
+ VALUE tokenizer_obj , VALUE parse_context_obj , VALUE block_body_obj )
41
+ {
42
+ block_body_t * body ;
43
+ BlockBody_Get_Struct (block_body_obj , body );
44
+ block_body_ensure_intermediate (body );
45
+
46
+ tokenizer_t * tokenizer ;
47
+ Tokenizer_Get_Struct (tokenizer_obj , tokenizer );
48
+
49
+ variable_parse_args_t parse_args = {
50
+ .markup = RSTRING_PTR (markup ),
51
+ .markup_end = RSTRING_PTR (markup ) + RSTRING_LEN (markup ),
52
+ .code = body -> as .intermediate .code ,
53
+ .code_obj = block_body_obj ,
54
+ .parse_context = parse_context_obj ,
55
+ };
56
+ internal_variable_compile (& parse_args , tokenizer -> line_number );
57
+ return Qnil ;
58
+ }
59
+
36
60
void liquid_define_tag ()
37
61
{
38
62
id_parse = rb_intern ("parse" );
@@ -42,4 +66,7 @@ void liquid_define_tag()
42
66
43
67
rb_define_singleton_method (cLiquidTag , "compile" , tag_class_compile , 5 );
44
68
rb_define_method (cLiquidTag , "compile" , tag_compile , 1 );
69
+
70
+ VALUE cLiquidEcho = rb_const_get (mLiquid , rb_intern ("Echo" ));
71
+ rb_define_singleton_method (cLiquidEcho , "compile" , echo_class_compile , 5 );
45
72
}
0 commit comments