templates

Django: Dynamic URL alias in templates

I am trying to use a template that contains a link such as this: <a href="{% url search query,page.previous_page_number %}">previous</a> I am trying to use it in multiple contexts; in other words, the URL alias "search" needs to point to a different target, depending on the view that renders the template. Is there a way to pass such ...

Is there a way to find out whether a class is a direct base of another class?

Hi I'm wondering whether there is a way to find out whether a class is a direct base of another class i.e. in boost type trait terms a is_direct_base_of function. As far as I can see boost doesn't see to support this kind of functionality which leads me to think that its impossible with the current C++ standard. The reason I want it is...

subclass as specialization - ie: adding a method in the specialization

I want to add an additional conversion operator to a specialization of a template -can a spelcialization inherit all methods from its main template ? template<class T> MyClass { public: operator Foo() { return(getAFoo()); } }; template<> MyClass<Bar> { public: // desire to ADD a method to a specialization yet inherit // a...

Alternative for templates in C++

I wrote code that looked like the following: template<typename CocoaWidget> class Widget : boost::noncopyable { private: CocoaWidget* mCocoaWidget; public: Widget() { mCocoaWidget = [[CocoaWidget alloc] init]; } // ... }; class Button : Widget<NSButton> { // ... }; But that doesn't work, because Mac Dev Center says:...

[C++] How to I check my template class is of a specific classtype?

In my template-ized function, I'm trying to check the type T is of a specific type. How would I do that? p/s I knew the template specification way but I don't want to do that. template<class T> int foo(T a) { // check if T of type, say, String? } Thanks! ...

Modern book on C++ templates

If I were to buy one and only one book on C++ templates which one would you recommend ? And why ? ...

Django Loading Templates with Inheritance from Specific Directory

In our project, we have a bunch of different templates that clients to choose from (for their webstore). The file layout is something like this: templates cart.html closed.html head.html standard bishop default indiana marley mocca nihilists raconteurs tripw...

How to build url in smarty template?

In template I have two strings which I want to combine in one. {assign var="bigUrl" value="Search?searchFor=Member&{$searchUrl}"} To be able to use variable {$bigUrl} below in template, like this: <a href={$bigUrl}>Link</a> When I write mentioned assignment smarty compiler report error: syntax error: invalid attribute name: '=' ...

C++ Template Quine

It is known that C++ templates are turing complete. As such it should be possible to output a quine that is essentially rendered at compile time. Does anyone know if such a quine has been written yet or where I could find one. ...

C++ template black magic

This needs only work in g++. I want a function template<typename T> std::string magic(); such that: Class Foo{}; magic<Foo>(); // returns "Foo"; Class Bar{}; magic<Bar>(); // returns "Bar"; I don't want this to be done via specialization (i.e. having to define magic for each type. I'm hoping to pull some macro/template black magic...

How to make reusable template for non-rectangular window with code-behind?

I've created non-rectangular window with my own style. It is Grid which contain custom close/min/max buttons, title area, 8 rectangles for resizing and of course Grid for window content (LayoutRoot). All of it working with c# event handlers at code-behind file. Now i need to make this construction reusable and available from toolbox at ...

How to create an automatic news site?

Hi, I've seen sites like this (http://www.tradename.net/) on the web that seem to be nothing more than a collection of news articles pulled in from different places - all seemingly automated... I would like to know how can I create something like this that: (a) either automatically, one its own pulls data from different news feeds and c...

How do I set a background image for each item of ListView in Android?

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="?android:attr/listPreferredItemHeight" android:padding="6dip"> <ImageView android:id="@+id/icon" android:layout_width="wrap_content" ...

Magento: Multiple calls to same block template with cache on

Hi all, I am calling a block multiple times in the footer of my site as follows: <reference name="footer"> <block type="catalog/navigation" name="footer.category.occasion" as="cat_occasion"> <action method="setTemplate"><template>catalog/category/menu.phtml</template></action> <action method="setData"><name>categor...

Holding a generic type's instance - C++

I have a tree_node class and a tree class. template<typename T> class tree_node { public: tree_node(const std::string& key_, const T& value_) : key(key_), value(value_) { } private: T value; std::string key; }; template<typename T> class tree { public: tree() : root(new tree_node<T>("", ???)) { } private: ...

Best pratice to populate data in a template?

I am wondering what solutions out there for populating data for a template. Right now we store email templates in the datatabse with place holders in them. When we need to send out the emails, we would replace the actual value in for the place holder. This solution works, except it is very hard to debug. Thanks in advance. Angela ...

Joomla 1.5 - how to create a table in a component's view's template?

I'm trying to create a Joomla component that displays the contents of a database table as a table on-screen. In the com_<name>/views/<name>/view.html.php file, what is the best way to create an HTML table that looks like a standard Joomla table? Do I create the HTML table manually and decorate it with some CSS classes, or is there a stan...

DIV goes to another line when resizing the browser.

I have a main div, and inside it..I have 2 divs, both left aligned. For some reason(or property), when I drag the right of my firefox to make the browser smaller, the 2nd div goes on to the second line. I would like this div to stay on the first line, instead of jumping down a line. How can I do that? I am assuming overflow property? ...

IF in the Django template system

How do I do this: {% if thestring %} {% if thestring.find("1") >= 0 %} {% endif %} {% endif %} I am assuming I need to build a template filter? Will that work? ...

Fully specialised templates and dllexport

Hello, Microsoft says: “Templates cannot be used with functions declared with __declspec (dllimport) or __declspec (dllexport).” (link). What does this mean? Can I export a function which has a fully specialized template class reference as an argument? ...