Skip to content

Commit

Permalink
Improve template documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
José Valim committed Sep 7, 2012
1 parent 7b9f577 commit 1ccb03f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
16 changes: 15 additions & 1 deletion lib/dynamo/view.ex
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/dynamo/view/finder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion test/dynamo/view/finder_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 1ccb03f

Please sign in to comment.