Skip to content

Commit

Permalink
forgotten new file
Browse files Browse the repository at this point in the history
  • Loading branch information
craff committed Jul 5, 2023
1 parent e198b01 commit d02f555
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions examples/files/tyr.chaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<html>
<head>
<script type="ml/global">
type Async.session_data += Count of int
</script>
<script type="ml/prelude">
let cookies, session = Session.check ~init:(fun _ -> Count 0) request
let count =
match Session.get_session_data session with
| Count n -> n
| _ -> -12
| exception Not_found -> -100
let _ = Session.set_session_data session (Count (count+1))
</script>
</head>
<body>
<h1>dynamic hello!</h1>
<ul>
<li> item 1 </li>
<li> item 2 </li>
<li> item 3 </li>
<li> item 4 </li>
<li> views: <ML>
let _ = echo (string_of_int count);;
let _ = echo (if count mod 2 = 0 then
<p>even (<ML> ^ string_of_int count ^ </ML>)</p>
else <p>odd</p>)
</ML>
</li>
</ul>
<a href="."> escape from this file </a>
<br/>
request: <ML>
let _ = printf "%a" Request.pp request
</ML>
</body>
</html>

0 comments on commit d02f555

Please sign in to comment.