24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/codemodels/html/angular_embedding_rules.rb', line 24
def self.parser_considering_angular_embedded_code
js_parser = CodeModels::Js::DefaultParser
js_expression_parser = CodeModels::Js::ExpressionParser
p = Parser.new
ng_attribute_base_names = 'app','repeat','show','class','model','click','include'
ng_attribute_names = []
ng_attribute_base_names.each do |n|
ng_attribute_names<<"ng:#{n}"
ng_attribute_names<<"ng-#{n}"
end
p.register_embedded_parser(Java::NetHtmlparserJericho::Attribute,js_expression_parser) do |n,code|
ng_attribute_names.include?(n.name) ? attribute_value_pos(code,n) : nil
end
p.register_embedded_parser(Java::NetHtmlparserJericho::Element,js_expression_parser) do |n,code|
res = []
if n.name!='script'
n.text_blocks(code).each do |tb|
tb_start = tb.source.position.begin_point.to_absolute_index(code)
res.concat(instances_of_escaped_text(code,tb.value,tb_start))
end
end
res
end
p.register_embedded_parser(Java::NetHtmlparserJericho::Attribute,js_expression_parser) do |n,code|
content = n.value
if n.getValueSegment
bi = n.getValueSegment.begin
instances_of_escaped_text(code,content,bi)
else
[]
end
end
p
end
|