Replies: 4 comments 13 replies
-
Hey @ox-harris, I am going to be writing a compiler for OOHTML in rust. I was wondering, is there a way to take HTML as input to a template?? Eg: <head>
<template name="title-module">
<export name="title>
<nav>
<arg name="foo"/>
</nav>
</export>
</template>
</head>
<body>
<import name="title" template="title-module">
<arg name="foo">
<h1>This is a title!!<h1>
</arg>
</import>
</body> Which would output as: <body>
<nav>
<h1>This is a title!!</h1>
</nav>
</body> This would be a huge improvement for noScript users! |
Beta Was this translation helpful? Give feedback.
-
Indeed! And thanks for the good thinking! OOHTML would let you do this. And here is how it goes (from OOHTML v1.7.5):
Hope that looks good! It might also be good to see how this looks in the alternative import/export syntax that uses the
And that's it! Fewer elements up there! And talking about less code, the idea of default import/export in OOHTML could further simplify things as it lets us do without import and export IDs. Below we omit the
Then, if we were to have to structure the inherited content in some special way, we could use the template element:
|
Beta Was this translation helpful? Give feedback.
-
@ox-harris I have another few of questions. Question OneHow are CSS and JS imports handled? Are they imported inline or is the CSS moved to the head and the JS appended to the body? ExampleWould this: <!-- template.html -->
<export name="title>
<style type="text/css">
h1 {
color: white;
}
</style>
<h1>This is a title!!</h1>
<script> console.log("Title module has been imported")</script>
</export> <!-- import.html -->
<head>
<template name="title-module" src="/template.html"/>
</head>
<body>
<import template="title-module" name="title"/>
<import template="title-module" name="title"/>
</body> Compile to this: <head>
<style type="text/css">
h1 {
color: white;
}
</style>
</head>
<body>
<h1>This is a title!!</h1>
<h1>This is a title!!</h1>
<script> console.log("Title module has been imported")</script>
<script> console.log("Title module has been imported")</script>
</body> Or this: <body>
<style type="text/css">
h1 {
color: white;
}
</style>
<h1>This is a title!!</h1>
<script> console.log("Title module has been imported")</script>
<style type="text/css">
h1 {
color: white;
}
</style>
<h1>This is a title!!</h1>
<script> console.log("Title module has been imported")</script>
</body> Question TwoWhat is the correct way to import HTML templates from rel? Should they just be a HTML snippet like this? <export name="title>
<style type="text/css">
h1 {
color: white;
}
</style>
<h1>This is a title!!</h1>
<script> console.log("Title module has been imported")</script>
</export> Or should they be a whole document like this? <!DOCTYPE html>
<html lang="en">
<head>
<export name="title>
<style type="text/css">
h1 {
color: white;
}
</style>
<h1>This is a title!!</h1>
<script> console.log("Title module has been imported")</script>
</export>
</head> If you are just supposed to use the former, how should the browser handle tags such as head, body etc in the imports? Question ThreeWould it not be more prudent to use href attribute instead of rel for linking to templates? This would allow the importing of templates cross-origin. Eg: <template name="title-module" href="http://website/some/url/template.html"/> I believe the rel tag usually defines the type of relationship between a linked resource, not the location of the resource. <!-- rel="snippet" for non-well-formed HTML documents -->
<template name="title-module" href="http://website/some/url/template.html" rel="snippet" />
<!-- rel="document" for importing well-formed HTML documents -->
<template name="title-module" href="http://website/some/url/template.html" rel="document" /> |
Beta Was this translation helpful? Give feedback.
-
Pleased to announce our new OOHTML docs: https://webqit.io/tooling/oohtml |
Beta Was this translation helpful? Give feedback.
-
👋 Welcome!
We’re using Discussions as a place to connect with other members of our community. We hope that you:
build together 💪.
To get started, comment below with an introduction of yourself and tell us about what you do with this community.
Beta Was this translation helpful? Give feedback.
All reactions