Monday, October 16, 2017

Wrapping basic static HTML page in sites base template. How to?

Curious and I admit lazy question as I don't even know where to look or how for such a general idea. But there it is, I'd like to be able to write a static HTML file (like say about.html) and render that inside of the sites style and basic template.

So I have base.html for example, which contains say:

    {% block content %}{% endblock %}

and various views that start with:

    {% extends "myapp/base.html" %}

and define content blocks.

I'd like a simple filter perhaps (or tag) which loads a nominated static html file but has some rudimentary smarts in its rendering. For example using the h1 text as a page title, and inserting a table of contents of ann the h2 and other headers with links to the respective sections. The static HTML file then need only declare the headers and texts and the template filter/tag would weave it together in such a manner.

Is that a common sort of need, that;s been solved, and done? Just curious really. Seems a common need at my end ;-). Hence a classic application of the DRY principle, and generalizing the routine elements of Table of Contents building and linking.

Regards,

Bernd.

No comments:

Post a Comment