Permalink
Browse files

[enhance] Resource: xhtml ns only for doctype xhtml1_1

  • Loading branch information...
1 parent 425ef5f commit e360e9b1f77f3f6c4929b8b0e0ef36758e5f0791 @cedricss cedricss committed Apr 24, 2012
Showing with 13 additions and 6 deletions.
  1. +2 −5 stdlib/core/web/resource/resource.opa
  2. +11 −1 stdlib/core/web/resource/resource_private.opa
@@ -437,20 +437,17 @@ status_control(resource: resource, status: web_response) =
source(content: string, mimetype: string) =
raw_response(content, mimetype, {success})
-
static_styled_page(title:string, styles:list(string), body: xmlns): resource =
xml_content : xmlns =
- @xml(
- <html xmlns="http://www.w3.org/1999/xhtml">
+ Resource_private.xmlns_html_tag(
<head>
<title>{title}</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
{List.map(url -> @xml(<link rel="stylesheet" type="text/css" href="{url}" />), styles)}
</head>
<body>
{body}
- </body>
- </html>
+ </body>
)
string_content = Xmlns.serialize_to_string(xml_content)
raw_response(string_content, "text/html", {success})
@@ -533,6 +533,16 @@ shared_html5_header =
shared_xml_header =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
+html_tag(content) =
+ match default_doctype.get() with
+ | {xhtml1_1} -> <html xmlns="http://www.w3.org/1999/xhtml">{content}</html>
+ | _ -> <html>{content}</html>
+
+xmlns_html_tag(content) =
+ match default_doctype.get() with
+ | {xhtml1_1} -> @xml(<html xmlns="http://www.w3.org/1999/xhtml">{content}</html>)
+ | _ -> @xml(<html>{content}</html>)
+
/**
* Produce a response to a given request.
*
@@ -952,7 +962,7 @@ export_resource(external_css_files: list(string),
| {none} -> html_doctype_to_string(default_doctype.get())
page = Xhtml.of_string_unsafe(html_doctype) <+>
- <html xmlns="http://www.w3.org/1999/xhtml">{ready_head}{ready_body}</html>
+ html_tag(<>{ready_head}{ready_body}</>)
//Serialize and send
data = Xhtml.serialize_to_string(page)

0 comments on commit e360e9b

Please sign in to comment.