Permalink
Browse files

Improve template documentation

  • Loading branch information...
1 parent 7b9f577 commit 1ccb03fec199104cc290ded0ebc547ad85467ecd @josevalim josevalim committed Sep 7, 2012
Showing with 17 additions and 2 deletions.
  1. +15 −1 lib/dynamo/view.ex
  2. +1 −0 lib/dynamo/view/finder.ex
  3. +1 −1 test/dynamo/view/finder_test.exs
View
16 lib/dynamo/view.ex
@@ -1,5 +1,19 @@
defmodule Dynamo.View do
- defrecord Template, identifier: nil, format: nil, handler: nil, source: nil, ref: nil, updated_at: nil
+ defrecord Template, key: nil, identifier: nil, format: nil,
+ handler: nil, source: nil, updated_at: nil, ref: nil do
+ @moduledoc """
+ The template record is responsible to keep information about
+ templates to be rendered. It contains:
+
+ * `:key` - The key used to find the template
+ * `:identifier` - An unique identifier for the template, like its filesystem path
+ * `:format` - The template format
+ * `:handler` - The handler responsible for compiling the template
+ * `:source` - The template source code
+ * `:updated_at` - The last time the template was updated
+ * `:ref` - A reference for already compiled templates
+ """
+ end
defexception TemplateNotFound, query: nil, view_paths: nil do
def message(exception) do
View
1 lib/dynamo/view/finder.ex
@@ -44,6 +44,7 @@ defmodule Dynamo.View.PathFinder do
if tmpl do
Dynamo.View.Template[
+ key: template,
updated_at: File.stat!(tmpl).mtime,
identifier: tmpl,
handler: extname(tmpl),
View
2 test/dynamo/view/finder_test.exs
@@ -9,7 +9,7 @@ defmodule Dynamo.View.PathFinderTest do
test "finds available template" do
path = File.join(@view_path, "hello.html.eex")
- assert Dynamo.View.Template[identifier: ^path,
+ assert Dynamo.View.Template[identifier: ^path, key: "hello.html",
handler: "eex", format: "html"] = @finder.find "hello.html"
end

0 comments on commit 1ccb03f

Please sign in to comment.