Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naoto-ogawa/9c3be74067af77f09f34c9bab41a47a7 to your computer and use it in GitHub Desktop.
Save naoto-ogawa/9c3be74067af77f09f34c9bab41a47a7 to your computer and use it in GitHub Desktop.
An example of including template in EDE
  • structure
$ tree
.
└── view
    ├── base.html
    └── main.content.html
  • an including file.
$ cat view/base.html
<!DOCTYPE html>
<html lang="<%= current_language %>">
<head>
  <meta charset="utf-8" />
  <title><%= html_title %></title>
  <meta name="description" content="my description" />
  <meta name="keywords" content="some keywords" />
</head>
<body class="<%= body_css_classes %>">
  <div id="top-menu"></div>
  <div id="header"></div>
  <div id="main">
      <div id="content">{% include "main.content.html" %}</div>
  </div>
  <div id="footer"></div>
</body>
</html>
  • an included file
$ cat view/main.content.html
<div>
  main content
</div>
$
  • ghc
> let tmpl = parseFile "view/base.html"
> let env = fromPairs [] :: Object
> (fmap . fmap) (\x -> render x env) tmpl
Success (Success "<!DOCTYPE html>\n<html lang=\"<%= current_language %>\">\n<head>\n  <meta charset=\"utf-8\" />\n  <title><%= html_title %></title>\n  <meta name=\"description\" content=\"my description\" />\n  <meta name=\"keywords\" content=\"some keywords\" />\n</head>\n<body class=\"<%= body_css_classes %>\">\n  <div id=\"top-menu\"></div>\n  <div id=\"header\"></div>\n  <div id=\"
\">\n      <div id=\"content\"><div>\n  main content\n</div>\n</div>\n  </div>\n  <div id=\"footer\"></div>\n</body>\n</html>\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment