Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1786 Переглядів

I want to build a mini markup mechanism for PDF reports. How can I use regular expression in Qweb report to change the output?

I want to create a bold text string from * * a bold text string * *

For that I use

Bacon Burger

in my template. In my model (wich I inherit from sale.order) I define a method 

def minimarkupmagic(self,txt):
​txt = re.sub(r'\*{2,2}(.*?)\*{2,2}', r'\1', txt)
​txt = re.sub(r'_{2,2}(.*?)_{2,2}', r'\1', txt)
​txtArr = txt.split('\n')
​txt = '
'.join(txtArr)
​return txt

and send it to my template within 

docargs = {
...,
​'minimarkupmagic': self.minimarkupmagic
}

from def render_html().

It works half way: I only get an output like

in my report, so it seems that the method runs after the rendering of the HTML to PDF.


So how could I get my HTML get interpreted earlier and get my correct output?

Thnx!

EDIT: I just found the answer: I found out that it works if you use t-raw. I used t-esc... :-)

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
1
лют. 22
2742
2
серп. 25
1087
1
лист. 24
12748
0
серп. 24
17
0
січ. 24
1933