Terminology: pages vs. components
Magery is designed around custom HTML5 template tags that called 'components' (though sometimes confusingly referred to as templates in our docs). On the server-side these need to be placed into a full HTML document to be useful, on the client-side only the components are used.
I'm proposing we call all current templates using custom tags 'components', and we introduce a concept of 'pages' for use with server-side implementations.
A page might look something like this:
<!DOCTYPE html>
<html>
<head>
<title>{{ page.title }}</title>
</head>
<body>
<h1>Profile</h1>
<my-component user="{{ user }}"></my-component>
</body>
</html>
Which makes use of a component defined like this:
<template data-tagname="my-component">
Hello, {{ user.name }}!
</template>
In the server-side library you would call separate functions/methods/whatever to load components and pages, for example:
magery.load_components("./templates/components")
magery.load_pages("./templates/pages")
Components would be rendered using their tag name:
magery.render_component("my-component", data)
And pages would be rendered using the path to the template file:
magery.render_page("project/example.html", data)
Exactly how those server-side APIs look and how page paths are constructed will be up to server-side implementors - they can do whatever makes sense in their language.
I think having two separate loading mechanisms might not be necessary. Instead of doing:
magery.load_components("./templates/components")
magery.load_pages("./templates/pages")
It could just be:
magery.load_files("./templates")
Which would populate both pages and components.
That means it would be possible for a single file to potentially define both a page and components:
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
</head>
<body>
<template data-tagname="my-component">
Hello, {{ name }}!
</template>
</body>
</html>
With the above example both a page and a component (called my-component) are registered. Rendering the page would include the embedded component template.
In which case pages should just be referred to as files so it's clear you're simply rendering the whole file:
magery.render_component("my-component", data)
magery.render_file("path/to/file.html", data)
It's not clear to me why we need a page concept.
I think react use only components it allow to define content of the body and stuff in the header two (i think).
What would pages bring to the table ? Except beeing a top level component ?