Advanced XML language injections


I have some xml files in which I embed the python code and I'm using language injection for it. It is sort of working but not for 100%. Here is an example




  <code name = "__init__(self, *args, **kwargs)">


# Python code

super().__init__(*args, **kwargs)





The above xml should be "translated" to the following python code:

class Form1(FormBase):

 def __init__(self, *args, **kwargs):

  # Python code

  super().__init__(*args, **kwargs)


Now, my first question, is it possible to define language injection for the full path of the tag? I mean 'form/script/code'? Because it is working only if I specify "code" as local name in xml language injection.

For <script> I have defined prefix as "class Form1(FormBase):", but don't know if it's working, because hovering on "self" in the method definition doesn't show anything, only that is isn't used anywhere.

The <code> tag is working OK (I guess). But the injection for the <code>'s CDATA isn't working as a part of the function body. I have it defined as "code" as a local name in xml injection.

Indentations - Could I somehow specify, that the code in the <code> tag should be idented for some number of spaces/tabs?

Could I somehow view the "generated" code from the language injections?



Please sign in to leave a comment.