Welcome Guest, Not a member yet? Register   Sign In
Does the Template Parser class supports inheritance like Django's template?
#1

[eluser]tlam[/eluser]
I was testing Django's template's inheritance feature and noticed how useful it is. Does anyone know if it's possible to do something similar with CI's Template Parser? Here's what I was referring to for Django, lifted from http://docs.djangoproject.com/en/dev/top...lates/#id1:

The following is base.html
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;
&lt;head&gt;
    &lt;link rel="stylesheet" href="style.css" /&gt;
    &lt;title&gt;{% block title %}My amazing site{% endblock %}&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;
    <div id="sidebar">
        {% block sidebar %}
        <ul>
            <li><a href="/">Home</a></li>
            <li><a href="/blog/">Blog</a></li>
        </ul>
        {% endblock %}
    </div>

    <div id="content">
        {% block content %}{% endblock %}
    </div>
&lt;/body&gt;
&lt;/html&gt;

The sub template:
Code:
{% extends "base.html" %}

{% block title %}My amazing blog{% endblock %}

{% block content %}
{% for entry in blog_entries %}
    <h2>{{ entry.title }}</h2>
    <p>{{ entry.body }}</p>
{% endfor %}
{% endblock %}


Messages In This Thread
Does the Template Parser class supports inheritance like Django's template? - by El Forum - 04-20-2009, 02:48 PM



Theme © iAndrew 2016 - Forum software by © MyBB