Allow for templates/settings to be read and compiled.

This allows for the handlebars templates in the template/settings
subdirectory to be found and compiled.
This commit is contained in:
Brock Whittaker
2016-10-04 16:36:26 -07:00
committed by Tim Abbott
parent 82764d0215
commit 3efe3601b8
2 changed files with 5 additions and 4 deletions

View File

@@ -19,7 +19,8 @@ STATIC_PATH = 'static/'
def get_templates(): def get_templates():
# type: () -> List[str] # type: () -> List[str]
return glob.glob(os.path.join(STATIC_PATH, 'templates/*.handlebars')) return (glob.glob(os.path.join(STATIC_PATH, 'templates/*.handlebars')) +
glob.glob(os.path.join(STATIC_PATH, 'templates/settings/*.handlebars')))
def run(): def run():
# type: () -> None # type: () -> None

View File

@@ -146,9 +146,9 @@ class Command(makemessages.Command):
translation_strings = {} # type: Dict[str, str] translation_strings = {} # type: Dict[str, str]
dirname = self.get_template_dir() dirname = self.get_template_dir()
for filename in os.listdir(dirname): for dirpath, dirnames, filenames in os.walk(dirname):
if filename.endswith('handlebars'): for filename in [f for f in filenames if f.endswith(".handlebars")]:
with open(os.path.join(dirname, filename), 'r') as reader: with open(os.path.join(dirpath, filename), 'r') as reader:
data = reader.read() data = reader.read()
data = data.replace('\n', '\\n') data = data.replace('\n', '\\n')
translation_strings.update(self.extract_strings(data)) translation_strings.update(self.extract_strings(data))