Commits

Anonymous committed 133e1e8

sometimes you need to be exhaused by the flu to find a problem...

Comments (0)

Files changed (4)

sblog_util.erl

--module(sblog_util)
-
--export([to_existing_atom/1])
-
-
-
-% works like list_to_existing_atom, except can be list or binary and it
-% gives you the original value instead of an error if no existing atom.
-% function borrowed to couchdb
-to_existing_atom(V) when is_list(V)->
-    try list_to_existing_atom(V) catch _ -> V end;
-to_existing_atom(V) when is_binary(V)->
-    try list_to_existing_atom(?b2l(V)) catch _ -> V end;
-to_existing_atom(V) when is_atom(V)->
-    V.
-
-%% Render the Template via erlydtl
-render_template(File,Data) ->
-    FullPathToFile = sblog_deps:local_path(["templates",File]),
- 
-    %% Make a module name
-    F = lists:reverse(string:tokens(File,"/")),
-    [N,_] = string:tokens(hd(F),"."),
-    Mn = string:join([N,"template"],"_"),
-    ModName = list_to_atom(Mn),
- 
-    erlydtl:compile(FullPathToFile,ModName),
-    ModName:render(Data).
-
         controller,
         path_parts
     }).
+
+-define(b2l(V), binary_to_list(V)).
+-define(l2b(V), list_to_binary(V)).

src/sblog_util.erl

+-module(sblog_util).
+
+-export([to_existing_atom/1, render_template/2]).
+
+-include("sblog.hrl").
+
+% works like list_to_existing_atom, except can be list or binary and it
+% gives you the original value instead of an error if no existing atom.
+% function borrowed to couchdb
+to_existing_atom(V) when is_list(V)->
+    try list_to_existing_atom(V) catch _ -> V end;
+to_existing_atom(V) when is_binary(V)->
+    try list_to_existing_atom(?b2l(V)) catch _ -> V end;
+to_existing_atom(V) when is_atom(V)->
+    V.
+
+%% Render the Template via erlydtl
+render_template(File,Data) ->
+    FullPathToFile = sblog_deps:local_path(["templates",File]),
+ 
+    %% Make a module name
+    F = lists:reverse(string:tokens(File,"/")),
+    [N,_] = string:tokens(hd(F),"."),
+    Mn = string:join([N,"template"],"_"),
+    ModName = list_to_atom(Mn),
+ 
+    erlydtl:compile(FullPathToFile,ModName),
+    ModName:render(Data).
+

templates/base.html

     <header>
     </header>
 
-    {% block content %}{% endblock %}@
+    {% block content %}{% endblock %}
     <footer>
         <div id="copyright">
             <p>copyright &copy; 2009 <a href="/?">benoît chesneau</>.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.