templates

Combining regroup with get_foo_display in Django templates

I'm using the regroup template tag to group queryset output on a Choices field. In the model: RESOURCE_TYPES = ( ('tut','External tutorial'), ('read','Additional reading'), ('org','Company or organization'), ) restype = models.CharField('Resource type',max_length=6,choices=RESOURCE_TYPES) ...

Url for the current page from a Mako template in Pylons

I need to know the full url for the current page from within a Mako template file in Pylons. The url will be using in an iframe contained within the page so it needs to be known when the page is being generated rather than after the page hits the server or from the environment. (Not sure if I am communicating that last bit properly) ...

C++ Generic List Assignment

I've clearly been stuck in Java land for too long... Is it possible to do the C++ equivalent of the following Java code: interface Foo {} class Bar implements Foo {} static List<Foo> getFoo() { return new LinkedList<Foo>(); } static List<Bar> getBar() { return new LinkedList<Bar>(); } List<? extends Foo> stuff = getBar(); Wher...

setting the header of a response in python / django

This is my code: template = loader.get_template('blog/post.html') c = Context(parameterDict) return HttpResponse(template.render(c)) I am using this to render data into a template(contained in parameterDict). The problem is that parameterDict contains certain UTF characters like ®. This is causing a problem in my template...

Hidden Field asp.net

I want to hide columns in asp.net in GridView then access the values in GridViewSelectIndexChanged using vb.net. I am using hidden fields in the GridView. When I try to access gives me an error object reference not set to an instance here is the code <asp:GridView ID="GridView1" runat="server" OnSorting="GridView1_OnSorting" AllowPaging...

GridView on the select of row

I need to hide columns in GridView then access the values of these columns in GridViewSelectedIndex using vb.net When I set visible=false for Bound colums i cannot access the values ...

Syntax for specializing function templates

Is there a difference between the following approaches? // approach 1 namespace std { template<> void swap<Foo>(Foo& x, Foo& y) // note the <Foo> { x.swap(y); } } // approach 2 namespace std { template<> void swap(Foo& x, Foo& y) { x.swap(y); } } I stumpled upon this when I tried to s...

"Inherited" types using CRTP and typedef

The following code does not compile. I get an error message: error C2039: 'Asub' : is not a member of 'C' Can someone help me to understand this? Tried VS2008 & 2010 compiler. template <class T> class B { typedef int Asub; public: void DoSomething(typename T::Asub it) { } }; class C : public B<C> { public: typedef int Asub;...

Is this call to a function object inlined?

In the following code, Foo::add calls a function via a function object: struct Plus { inline int operator()(int x, int y) const { return x + y; } }; template<class Fct> struct Foo { Fct fct; Foo(Fct f) : fct(f) {} inline int add(int x, int y) { return fct(x,y); // same efficiency adding directly? } }; Is this th...

Notepad++ premade template

Hi, I have seen in videos, that people get html template by typing "html:5" or something like that (btw, they're not using notepad++). Is this possible in notepad++? Thanks. ...

Loop through custom template hooking thing

Hi, I am building a template system for emailing people that currently works in the format of: $array['key1'] = "text"; $array['key2'] = "more text"; <!--key1--> // replaced with *text* <!--key2--> // replaced with *more text* For this particular project I have a nested array with this kind of structure: $array['object1']['nest1']['...

What libraries use design patterns implemented with compile-time metaprogramming techniques?

Does anybody know of any libraries that use design patterns that are implemented using compile-time techniques e.g. template metaprogramming? I know that Loki implements a few but I need to find other libraries. ...

Forcing a templated object to construct from a pointer

I have a fictional class: template<typename T> class demonstration { public: demonstration(){} ... T *m_data; } At some point in the program's execution, I want to set m_data to a big block of allocated memory and construct an object T there. At the moment, I've been using this code: void construct() { *m_data ...

Scope quandary with namespaces, function templates, and static data

This scoping problem seems like the type of C++ quandary that Scott Meyers would have addressed in one of his Effective C++ books. I have a function, Analyze, that does some analysis on a range of data. The function is called from a few places with different types of iterators, so I have made it a template (and thus implemented it in a...

Question regarding C++ Templates

I used a simple class for a test program about templates, this is what I did: template <typename T> class test { public: test<T>::test(); T out(); }; template <typename T> test<T>::test() { } T test<T>::out() { } int main() { //test<int> t; } But when I try to compile it says 'T' : undeclared identifier and use of class...

signature output operator overload

hi, do you know, how to write signature of a function or method for operator<< for template class in C++? I want something like: template <class A> class MyClass{ public: friend ostream & operator<<(ostream & os, MyClass<A> mc); } ostream & operator<<(ostream & os, MyClass<A> mc){ // some code return os; } But this just won't ...

Returning modified data to a template

I need to amend QuerySet data when i return it to a template. for example, model.objects.all() returns a date (with other fields), but i also want to return the number of days since that date has passed. This is so that in the template, i can say "you last logged in 4 days ago". What is the best way to do this? ...

WPF ListBox's scrollviewer customizable so that there is no Scrollbar, only RepeatButtons

Hi I would like to customize the scrollbars of a listbox's scrollviewer in such a way that the scrollbar only consists of a RepeatButton for scrolling up and a Repeatbutton for scrolling down. Nothing else. There should be no scrollbar (track) between the buttons. One button should be to the left of the ItemsPanel (scroll up) and the oth...

Class template specializations with shared functionality

I'm writing a simple maths library with a template vector type: template<typename T, size_t N> class Vector { public: Vector<T, N> &operator+=(Vector<T, N> const &other); // ... more operators, functions ... }; Now I want some additional functionality specifically for some of these. Let's say I want functions x() a...

Design support for templated UserControl

Hello, I have created a real simple templated UserControl using the following tutorial: http://msdn.microsoft.com/en-us/library/36574bf6(VS.80).aspx I can now add this control to my mvc 2.0 application using: <components:Box BoxType="Help" Title="Content Title" runat="server"> <Content> <%: Html.TextBox("test") %> ...