[ckan-dev] Pylons context object

Pabitra Dash pkdash_reena at hotmail.com
Fri Mar 14 15:29:22 UTC 2014


Sure, I could do this way. Is there any difference in performance between passing data to a template vs calling a function inside the template to get the data? I am guessing passing data is a better approach. 
 
Pabitra


 
Date: Fri, 14 Mar 2014 11:23:33 -0400
From: stephane at opennorth.ca
To: ckan-dev at lists.okfn.org
Subject: Re: [ckan-dev] Pylons context object

Indeed...
But from a quick look, it seems that most of the snippet calls are inside a dedicated block, so overriding the snippet call to pass a new variable should not be a big deal. Except if you case is different..

Examples:

  {% block package_resources %}    {% snippet "package/snippets/resources_list.html", pkg=pkg, resources=pkg.resources %}
  {% endblock %}
  {% block package_tags %}    {% snippet "package/snippets/tags.html", tags=pkg.tags %}
  {% endblock %}
  {% block package_additional_info %}
    {% snippet "package/snippets/additional_info.html", pkg_dict=pkg %}  {% endblock %}


On Fri, Mar 14, 2014 at 10:44 AM, Pabitra Dash <pkdash_reena at hotmail.com> wrote:




Passing variable to snippet would work only when you are overriding both the template that calls the snippet and the snippet itself. In my case I am overriding only the snippet.
 
Pabitra


 
Date: Thu, 13 Mar 2014 19:37:04 -0400
From: stephane at opennorth.ca
To: ckan-dev at lists.okfn.org

Subject: Re: [ckan-dev] Pylons context object

If I remember well, it is possible to pass some variables to snippets without using function.
Here is an example:    {% snippet "package/snippets/resources_list.html", pkg=pkg, resources=pkg.resources %}



from https://github.com/ckan/ckan/blob/master/ckan/templates/package/read.html



On Thu, Mar 13, 2014 at 4:32 PM, Pabitra Dash <pkdash_reena at hotmail.com> wrote:




Thanks Khalegh for letting me know this secret. It solved the problem for me.
 
Pabitra 


 
From: khalegh at highwaythreesolutions.com


Date: Thu, 13 Mar 2014 13:12:09 -0700
To: ckan-dev at lists.okfn.org
Subject: Re: [ckan-dev] Pylons context object

Hi Pabitra,

context object is not accessible in snippets and package_metadata_fields.html is a snippet. I had the same problem and I used helper functions instead.
Best,Khalegh 


On Mar 13, 2014, at 12:20 PM, Pabitra Dash <pkdash_reena at hotmail.com> wrote:


Hi All,
 
Any idea why the context object (c) may not be available in a template. Jinja is throwing an error 'c' undefined. I am getting this error in my extended template 'package_metadata_fields.html' where I am trying to access the 'c.user' object.


 
Thanks
Pabitra


_______________________________________________
ckan-dev mailing list
ckan-dev at lists.okfn.org
https://lists.okfn.org/mailman/listinfo/ckan-dev


Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev

_______________________________________________
ckan-dev mailing list
ckan-dev at lists.okfn.org
https://lists.okfn.org/mailman/listinfo/ckan-dev
Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev 		 	   		  

_______________________________________________

ckan-dev mailing list

ckan-dev at lists.okfn.org

https://lists.okfn.org/mailman/listinfo/ckan-dev

Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev




-- 
Stéphane GuidoinDirector, Transportation
Open North
514-862-0084

http://opennorth.caTwitter: @opennorth / @hoedic


_______________________________________________
ckan-dev mailing list
ckan-dev at lists.okfn.org
https://lists.okfn.org/mailman/listinfo/ckan-dev
Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev 		 	   		  

_______________________________________________

ckan-dev mailing list

ckan-dev at lists.okfn.org

https://lists.okfn.org/mailman/listinfo/ckan-dev

Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev







_______________________________________________
ckan-dev mailing list
ckan-dev at lists.okfn.org
https://lists.okfn.org/mailman/listinfo/ckan-dev
Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20140314/19b680b0/attachment-0003.html>


More information about the ckan-dev mailing list