def js_templates(self, prefix, src, name=None):
        """
        :param prefix: the library name (lux, mylib, ...)
        :param src: the source directory of files
        :param name: when ``None`` don't recursively walk subpaths
        :return: a dictionary for requirejs
        """
        templates = os.path.join(src, 'templates')
        if not os.path.isdir(templates):
            return

        tmpl = 'templates'
        bits = [prefix]
        if name:
            bits.append(name)
        target_dir = self.js_target(*bits)
        bits.append(tmpl)
        file_name = '/'.join(bits)
        module_name = '.'.join(bits)
        cache = []
        cache_template = self.template('template.cache.js')

        for filename in os.listdir(templates):
            if filename.endswith('.tpl.html'):
                with open(os.path.join(templates, filename), 'r') as fp:
                    text = fp.read()
                file_module_name = '%s/%s' % (file_name, filename)
                text = ' +\n'.join(self.lines(text))
                cache.append(cache_template.safe_substitute(
                    dict(text=text, file_name=file_module_name)))

        if cache:
            if not os.path.isdir(target_dir):
                os.makedirs(target_dir)
            target = os.path.join(target_dir, '%s.js' % tmpl)

            cache = '\n'.join(cache)
            template = self.template('template.module.js')
            template = template.safe_substitute(
                dict(cache=cache, module_name=module_name)
            )
            with open(target, 'w') as fp:
                fp.write(template)

            self.write('"%s" created' % target)
dataset/ETHPy150Open quantmind/lux/lux/core/commands/media.py/MediaBuilder.js_templates/original