How can I introspect a freemarker template to find out what variables it uses?

前端 未结 7 572
无人共我
无人共我 2021-01-01 15:27

I\'m not at all sure that this is even a solvable problem, but supposing that I have a freemarker template, I\'d like to be able to ask the template what variables it uses.<

7条回答
  •  無奈伤痛
    2021-01-01 16:20

    Execute following regex on the template:

    (?<=\$\{)([^\}]+)(?=\})
    
    • (?<=\$\{) Matches everything followed by ${
    • ([^\}]+) Matches any string not containing }
    • (?=\}) Matches everything before }

提交回复
热议问题