Example #1
0
    def preprocess(self, source, name, filename=None):
        if not name or os.path.splitext(name)[1] not in self.HAML_EXTENSIONS:
            return source

        compiler = Compiler()
        try:
            return compiler.process(source)
        except Exception, e:
            raise TemplateSyntaxError(e, None, name=name, filename=filename)
Example #2
0
def preBuild(site):
    for path in fileList(site.paths['pages']):

        #only file ends with haml
        if not path.endswith('.haml'):
            continue

        #read the lines
        haml_lines = codecs.open(path, 'r',
                                 encoding='utf-8').read().splitlines()

        #compile haml to html
        compiler = Compiler()
        output = compiler.process_lines(haml_lines)

        #replace path
        outPath = path.replace('.haml', '.html')

        #write the html file
        with open(outPath, 'w') as f:
            f.write(output)

        CLEANUP.append(outPath)
Example #3
0
def hamlpy (t):
    #from hamlpy.hamlpy import Compiler
    return Compiler().process(t)