erlydtl/erlydtl — pull request #166 by choptastic (2014-04-18 06:44:16+00:00)
Title: Fix ensure_dir when debug_root is specified

From commit's extended message:

Previously, we were checking if the directory exists, but not checking
it with respect to the doc_root exists. Instead, we were ensuring the
directory with respect only to the originally provided "debug_root".

This patch ensures (har har) that when we are ensuring the directory for
debug purposes, that it includes the full path to the file.

*Additionally* calling filelib:ensure_dir(Dir) will only ensure the
directories up to the *parent* of Dir. It's a little bit wonky, so
typically one would append a "dummy" file to a Dir path. But we don't
need to do this since Abs is itself a file, so we ensure_dir(Abs), and
it'll ensure all the directories correctly.

Example: filelib:ensure_dir("/foo/bar/whatever/something"), will only
ensure that the directories "/foo/bar/whatever" exist and will create
them if necessary. "something" is not actually used.

The short of it is that this will fix debug_root if a doc_root is
specified, and the File to be compiled is specified with directories as
well, such as "src/view/whatever.html". Further, it shortens the code
up a bit, removing the unnecessary is_dir call.