Skip to content

Commit

Permalink
Skip templates when using the dev server.
Browse files Browse the repository at this point in the history
Fixes #26
  • Loading branch information
mblayman committed Jun 10, 2015
1 parent 4e2e794 commit b719c14
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
6 changes: 6 additions & 0 deletions handroll/director.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ def process_file(self, filepath):
# Skip files in the output directory.
if self.is_in_output(filepath):
return
# Skip templates.
if self.catalog.is_template(filepath):
return

signals.pre_composition.send(self)
dirname = os.path.dirname(filepath)
Expand All @@ -72,6 +75,9 @@ def process_directory(self, directory):
# Skip files in the output directory.
if self.is_in_output(directory):
return
# Skip templates.
if self.catalog.is_template(directory):
return

signals.pre_composition.send(self)
dirname, basedir = os.path.split(directory)
Expand Down
29 changes: 29 additions & 0 deletions handroll/tests/test_director.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,32 @@ def test_process_directory_triggers_pre_composition(self, signals):
director.process_directory(directory)

signals.pre_composition.send.assert_called_once_with(director)

def test_process_file_ignores_templates(self):
config = Configuration()
site = self.factory.make_site()
default = os.path.join(site.path, 'template.html')
open(default, 'w').close()
config.outdir = os.path.join(site.path, 'outdir')
os.mkdir(config.outdir)
director = Director(config, site, [])

director.process_file(default)

default_output = os.path.join(config.outdir, 'template.html')
self.assertFalse(os.path.exists(default_output))

def test_process_directory_ignores_templates(self):
config = Configuration()
site = self.factory.make_site()
config.outdir = os.path.join(site.path, 'outdir')
os.mkdir(config.outdir)
director = Director(config, site, [])
directory = os.path.join(director.catalog.templates_path, 'test')
os.makedirs(directory)

director.process_directory(directory)

directory_output = os.path.join(
config.outdir, director.catalog.TEMPLATES_DIR, 'test')
self.assertFalse(os.path.exists(directory_output))

0 comments on commit b719c14

Please sign in to comment.