<s> import re <EOL> from jinja2 . ext import Extension <EOL> class IncludeWith ( Extension ) : <EOL> """<STR_LIT>""" <EOL> rx = re . compile ( <EOL> r'<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> re . IGNORECASE ) <EOL> def preprocess ( self , source , name , filename = None ) : <EOL> lastpos = <NUM_LIT:0> <EOL> while <NUM_LIT:1> : <EOL> m = self . rx . search ( source , lastpos ) <EOL> if not m : <EOL> break <EOL> lastpos = m . end ( ) <EOL> d = m . groupdict ( ) <EOL> context = d [ '<STR_LIT>' ] . strip ( ) <EOL> if context == '<STR_LIT>' : <EOL> continue <EOL> source = '<STR_LIT>' . join ( [ <EOL> source [ : m . start ( ) ] , <EOL> '<STR_LIT>' , context , '<STR_LIT>' , <EOL> '<STR_LIT>' , d [ '<STR_LIT>' ] . strip ( ) , '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> source [ m . end ( ) : ] <EOL> ] ) <EOL> return source </s>
