Loading ...
Sorry, an error occurred while loading the content.

[Cheetahtemplate-discuss] Basic use of #extends

Expand Messages
  • Chris Stoyles
    Hi Everyone, I am trying to do something which I think should be fairly trivial, but am yet to work out how to do it in Cheetah. I want a base template for my
    Message 1 of 4 , Mar 23, 2010
    • 0 Attachment
      Hi Everyone,

      I am trying to do something which I think should be fairly trivial, but am yet to work out how to do it in Cheetah. I want a base template for my site (base.html) with a block in it (#block main_content) which I can fill-out or override in another template. 

      In Django I would include the following statement at the top of my other template:
      {extends "/var/www/my/app/templates/base.html"}

      Then to fill in one of the blocks defined in base.html I would just do this:
      {% block main_content %}
      ...html...
      {% endblock %}

      I've tried my best to understand this page: http://www.cheetahtemplate.org/docs/users_guide_html_multipage/inheritanceEtc.extends.html but with no luck.

      Hopefully someone out there can quickly explain to me how I should go about this.

      Thanks,
      Chris.
    • Chris Stoyles
      Ok so I worked it out last night. What wasn t obvious to me (which perhaps would have been had I read the user guide in its entirety) was that you create your
      Message 2 of 4 , Mar 24, 2010
      • 0 Attachment
        Ok so I worked it out last night. What wasn't obvious to me (which perhaps would have been had I read the user guide in its entirety) was that you create your HTML template (base.tmpl) first. You then run the "cheetah compile /path/to/base.tmpl" which creates your base.py file. I followed the same steps for my page template and then everything fell into place. Hopefully I've not wasted anyone's time.

        Thanks,
        Chris.

        On Wed, Mar 24, 2010 at 2:12 PM, Chris Stoyles <chriss@...> wrote:
        Hi Everyone,

        I am trying to do something which I think should be fairly trivial, but am yet to work out how to do it in Cheetah. I want a base template for my site (base.html) with a block in it (#block main_content) which I can fill-out or override in another template. 

        In Django I would include the following statement at the top of my other template:
        {extends "/var/www/my/app/templates/base.html"}

        Then to fill in one of the blocks defined in base.html I would just do this:
        {% block main_content %}
        ...html...
        {% endblock %}

        I've tried my best to understand this page: http://www.cheetahtemplate.org/docs/users_guide_html_multipage/inheritanceEtc.extends.html but with no luck.

        Hopefully someone out there can quickly explain to me how I should go about this.

        Thanks,
        Chris.

      • Tavis Rudd
        Hi Chris, You can also use the cheetah import hooks to compile the base class dynamically (see the module Cheetah.ImportHooks). Cheers, Tavis ... Download
        Message 3 of 4 , Mar 24, 2010
        • 0 Attachment
          Hi Chris,
          You can also use the cheetah import hooks to compile the base class
          dynamically (see the module Cheetah.ImportHooks).
          Cheers,
          Tavis

          On Thu, 25 Mar 2010, Chris Stoyles wrote:

          > Ok so I worked it out last night. What wasn't obvious to me (which perhaps
          > would have been had I read the user guide in its entirety) was that you
          > create your HTML template (base.tmpl) first. You then run the "cheetah
          > compile /path/to/base.tmpl" which creates your base.py file. I followed the
          > same steps for my page template and then everything fell into place.
          > Hopefully I've not wasted anyone's time.
          >
          > Thanks,
          > Chris.
          >
          > On Wed, Mar 24, 2010 at 2:12 PM, Chris Stoyles <chriss@...> wrote:
          >
          >> Hi Everyone,
          >>
          >> I am trying to do something which I think should be fairly trivial, but am
          >> yet to work out how to do it in Cheetah. I want a base template for my site
          >> (base.html) with a block in it (#block main_content) which I can fill-out or
          >> override in another template.
          >>
          >> In Django I would include the following statement at the top of my other
          >> template:
          >> {extends "/var/www/my/app/templates/base.html"}
          >>
          >> Then to fill in one of the blocks defined in base.html I would just do
          >> this:
          >> {% block main_content %}
          >> ...html...
          >> {% endblock %}
          >>
          >> I've tried my best to understand this page:
          >> http://www.cheetahtemplate.org/docs/users_guide_html_multipage/inheritanceEtc.extends.html but
          >> with no luck.
          >>
          >> Hopefully someone out there can quickly explain to me how I should go about
          >> this.
          >>
          >> Thanks,
          >> Chris.
          >>
          >

          ------------------------------------------------------------------------------
          Download Intel® Parallel Studio Eval
          Try the new software tools for yourself. Speed compiling, find bugs
          proactively, and fine-tune applications for parallel performance.
          See why Intel Parallel Studio got high marks during beta.
          http://p.sf.net/sfu/intel-sw-dev
          _______________________________________________
          Cheetahtemplate-discuss mailing list
          Cheetahtemplate-discuss@...
          https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
        • Chris Stoyles
          Wow that works beautifully :) Thanks! Chris. ... Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs
          Message 4 of 4 , Mar 24, 2010
          • 0 Attachment
            Wow that works beautifully :) Thanks!

            Chris.

            On Thu, Mar 25, 2010 at 8:33 AM, Tavis Rudd <tavis@...> wrote:
            Hi Chris,
            You can also use the cheetah import hooks to compile the base class dynamically (see the module Cheetah.ImportHooks).
            Cheers,
            Tavis


            On Thu, 25 Mar 2010, Chris Stoyles wrote:

            Ok so I worked it out last night. What wasn't obvious to me (which perhaps
            would have been had I read the user guide in its entirety) was that you
            create your HTML template (base.tmpl) first. You then run the "cheetah
            compile /path/to/base.tmpl" which creates your base.py file. I followed the
            same steps for my page template and then everything fell into place.
            Hopefully I've not wasted anyone's time.

            Thanks,
            Chris.

            On Wed, Mar 24, 2010 at 2:12 PM, Chris Stoyles <chriss@...> wrote:

            Hi Everyone,

            I am trying to do something which I think should be fairly trivial, but am
            yet to work out how to do it in Cheetah. I want a base template for my site
            (base.html) with a block in it (#block main_content) which I can fill-out or
            override in another template.

            In Django I would include the following statement at the top of my other
            template:
            {extends "/var/www/my/app/templates/base.html"}

            Then to fill in one of the blocks defined in base.html I would just do
            this:
            {% block main_content %}
            ...html...
            {% endblock %}

            I've tried my best to understand this page:
            http://www.cheetahtemplate.org/docs/users_guide_html_multipage/inheritanceEtc.extends.html but
            with no luck.

            Hopefully someone out there can quickly explain to me how I should go about
            this.

            Thanks,
            Chris.



          Your message has been successfully submitted and would be delivered to recipients shortly.