Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Including Javascript Files in Chameleon Templates
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Vincent Catalano  
View profile  
 More options Apr 18 2012, 7:19 pm
From: Vincent Catalano <vinc...@vincentcatalano.com>
Date: Wed, 18 Apr 2012 16:19:40 -0700
Local: Wed, Apr 18 2012 7:19 pm
Subject: Including Javascript Files in Chameleon Templates
Each of my views has a separate template and each of these templates
extends the base template. However, each of my views uses a different
Javascript file. What is the best way to include different Javascript
files for each page using Chameleon templates? Thanks for your help!

--Vincent


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Daniel Nouri  
View profile  
 More options Apr 18 2012, 7:48 pm
From: Daniel Nouri <daniel.no...@gmail.com>
Date: Thu, 19 Apr 2012 01:48:53 +0200
Local: Wed, Apr 18 2012 7:48 pm
Subject: Re: Including Javascript Files in Chameleon Templates
On Thu, Apr 19, 2012 at 1:19 AM, Vincent Catalano

<vinc...@vincentcatalano.com> wrote:
> Each of my views has a separate template and each of these templates
> extends the base template. However, each of my views uses a different
> Javascript file. What is the best way to include different Javascript
> files for each page using Chameleon templates? Thanks for your help!

1) A lo-fi way of doing this is to put this in your base template
where you want your <script> tags to appear:

    <more tal:omit-tag="" metal:define-slot="more-scripts"></more>

Then in your view's template, use something like:

    <more tal:omit-tag="" metal:fill-slot="more-scripts">
        <script src="myscript.js" type="text/javascript"></script>
    </more>

2) Consider putting all your scripts into a single, compressed file.
If they aren't huge, there's the benefit of not sending a HTTP request
for each one of your scripts.

3) Use something like fanstatic for when things are more complex:
http://www.fanstatic.org http://pypi.python.org/pypi/pyramid_fanstatic

Daniel


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Noe Nieto  
View profile  
 More options Apr 18 2012, 7:39 pm
From: Noe Nieto <nni...@noenieto.com>
Date: Wed, 18 Apr 2012 18:39:04 -0500
Local: Wed, Apr 18 2012 7:39 pm
Subject: Re: Including Javascript Files in Chameleon Templates

You can define a javascript/css slot in your master template and fill them
in your templates.

Example of master.pt:

<html>

<head>
    <tal:comment replace="nothing">
        Various slots where you can insert elements in the header from a
template.
    </tal:comment>
    <metal:styleslot define-slot="style_slot" />
    <metal:javascriptslot define-slot="javascript_head_slot" />
</head>

<body>
 <! -- bla bla bla stuff -->
</body>

</html>

Example of some foo.pt

<!DOCTYPE html>
<html lang="en"
      xmlns="http://www.w3.org/1999/xhtml"
      xml:lang="en"
      xmlns:tal="http://xml.zope.org/namespaces/tal"
      xmlns:metal="http://xml.zope.org/namespaces/metal"
      metal:use-macro="master_template.macros['master']">
<head>
<metal:css fill-slot="style_slot">
  <link rel="stylesheet"
href="${request.static_url('spionisto.web:static/css/controlpanel.css')}" />
</metal:css>
<metal:js fill-slot="javascript_head_slot">
  <script
src="${request.static_url('spionisto.web:static/js/libs/jquery-1.5.1.min.js ')}"
type="text/javascript"></script>
  <script
src="${request.static_url('spionisto.web:static/js/libs/jquery.tools.min.js ')}"
type="text/javascript"></script>
  <script src="${request.static_url('spionisto.web:static/js/viewer.js')}"
type="text/javascript"></script>
</metal:js>
</head>
<body>
  <metal:content fill-slot="maincontent_slot">
    <article>
      <header>
        <h2>Add camera</h2>
        <form tal:replace="structure form" />
      </header>
    </article>
  </metal:content>
</body>
</html>

--
Noe

2012/4/18 Vincent Catalano <vinc...@vincentcatalano.com>

--
---
Noe Nieto
NNieto Consulting Services
M: nni...@noenieto.com
W: http://noenieto.com
T:  @tzicatl <https://twitter.com/#%21/tzicatl>
Li: Perfil en LinkedIn <http://www.linkedin.com/profile/view?id=84300665>

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »