Commit a6803dfa6c24dbaa475c5157aca08877ebce32ee

Thomas de Grivel 2024-09-13T23:16:17

split templates and controllers and views

diff --git a/test/httpd/app/controllers/doc_controller.kc3 b/test/httpd/app/controllers/doc_controller.kc3
index 93c4418..b976cbc 100644
--- a/test/httpd/app/controllers/doc_controller.kc3
+++ b/test/httpd/app/controllers/doc_controller.kc3
@@ -61,11 +61,11 @@ defmodule DocController do
 
   def show_html = fn (path_html) {
     index = doc_index("./doc/", path_html)
-    menu = EKC3.render_file("app/templates/doc/menu.html.ekc3")
+    menu = DocView.render_menu(index)
     title = "kc3-lang.org"
     html = File.read(path_html)
-    page = EKC3.render_file("app/templates/doc/show.html.ekc3")
-    body = EKC3.render_file("app/templates/layout.html.ekc3")
+    page = DocView.render_show(menu, html)
+    body = LayoutView.render(title, page)
     %HTTP.Response{body: body}
   }
 
diff --git a/test/httpd/app/views/doc_view.kc3 b/test/httpd/app/views/doc_view.kc3
new file mode 100644
index 0000000..c01ed1f
--- /dev/null
+++ b/test/httpd/app/views/doc_view.kc3
@@ -0,0 +1,11 @@
+defmodule DocView do
+
+  def render_menu = fn (index) {
+    EKC3.render_file("app/templates/doc/menu.html.ekc3")
+  }
+
+  def render_show = fn (menu, html) {
+    EKC3.render_file("app/templates/doc/show.html.ekc3")
+  }
+
+end
diff --git a/test/httpd/app/views/layout_view.kc3 b/test/httpd/app/views/layout_view.kc3
new file mode 100644
index 0000000..aa85042
--- /dev/null
+++ b/test/httpd/app/views/layout_view.kc3
@@ -0,0 +1,7 @@
+defmodule LayoutView do
+
+  def render = fn (title, page) {
+    EKC3.render_file("app/templates/layout.html.ekc3")
+  }
+
+end