@apply_to_text_file
def php_template_injection(data):
 import re
 template = re.search('<\\!-- __NIKOLA_PHP_TEMPLATE_INJECTION source\\:(.*) checksum\\:(.*)__ -->', data)
 if template:
  source = template.group(1)
  with io.open(source, 'r', encoding='utf-8') as in_file:
   phpdata = in_file.read()
  _META_SEPARATOR = (((((('(' + (os.linesep * 2)) + '|') + ('\n' * 2)) + '|') + ('\r\n' * 2)) + ')')
  phpdata = re.split(_META_SEPARATOR, phpdata, maxsplit=1)[(-1)]
  phpdata = re.sub(template.group(0), phpdata, data)
  return phpdata
 else:
  return data

@ apply_to_text_file def php_template_injection ( data ) : import re template = re . search ( '<\\!-- __NIKOLA_PHP_TEMPLATE_INJECTION source\\:(.*) checksum\\:(.*)__ -->' , data ) if template : source = template . group ( 1 ) with io . open ( source , 'r' , encoding = 'utf-8' ) as in_file : phpdata = in_file . read ( ) _META_SEPARATOR = ( ( ( ( ( ( '(' + ( os . linesep * 2 ) ) + '|' ) + ( '\n' * 2 ) ) + '|' ) + ( '\r\n' * 2 ) ) + ')' ) phpdata = re . split ( _META_SEPARATOR , phpdata , maxsplit = 1 ) [ ( - 1 ) ] phpdata = re . sub ( template . group ( 0 ) , phpdata , data ) return phpdata else : return data
insert php code into nikola templates .