templates

How would you share a theme between a Django app and a Wordpress blog?

Trying to keep a consistent look & feel between a django site and a wordpress blog is turning into somewhat of a pain and I'm wondering if there's a way to set it up so that stuff only needs to be changed in one place. Most of the appearance stuff that changes is in the header and footer which for Wordpress is in header.php and footer.p...

Refactoring function pointers to some form of templating

Bear with me as I dump the following simplified code: (I will describe the problem below.) class CMyClass { ... private: HRESULT ReadAlpha(PROPVARIANT* pPropVariant, SomeLib::Base *b); HRESULT ReadBeta(PROPVARIANT* pPropVariant, SomeLib::Base *b); typedef HRESULT (CMyClass::*ReadSignature)(PROPVARIANT* pPropVariant, SomeLib::Bas...

When does template instantiation bloat matter in practice?

It seems that in C++ and D, languages which are statically compiled and in which template metaprogramming is a popular technique, there is a decent amount of concern about template instantiation bloat. It seems to me like mostly a theoretical concern, except on very resource-constrained embedded systems. Outside of the embedded space,...

Partially defaulting template arguments using typedefs?

I am trying to do something like this: template <typename T,bool Strong=true> class Pointer {...}; template <typename T> typedef Pointer<T,false> WeakPointer; But this is a compile error ("a typedef template is illegal" VC). I am trying to avoid doing this using inheritance, beacuse that's more unnecessary work (rewriting constructo...

C++ instantiate templates in loop

hi I have have a factory class, which needs to instantiate several templates with consecutive template parameters which are simple integers. How can I instantiate such template functions without unrolling the entire loop? The only thing that can think of is using boost pre-processor. Can you recommend something else, which does not d...

HTML template + JSON vs Server HTML

What do you think is better? Use for Ajax result: HTML that was generated on server Return Data that would be used within template? I think plus for server rendering are escaping, easy more complex logic, when much data needed! ...

C++ overloading operator= in template

Hi all I'm having trouble with C++ template operator= What I'm trying to do: I'm working on a graph algorithm project using cuda and we have several different formats for benchmarking graphs. Also, I'm not entirely sure what type we'll end up using for the individual elements of a graph. My goal is to have a templated graph class and a...

Problem with logic in Django template

Supose this portion of a Django template. regs is a list of Reg objects. Reg.editable is a BooleanField. I want to render a radio button per element in the list. If r.editable is False, the radio button must be disabled: {% for r in regs %} <input type="radio" value="{{ forloop.counter }}" {% if forloop.first %}checked="checked"{% endif...

C++ Templates vs. Aggregation

Consider the following piece of code: class B { private: // some data members public: friend bool operator==(const B&,const B&); friend ostream& operator<<(ostream&,const B&); // some other methods }; template <typename T=B> class A { private: // some data members vector<vector<T> > vvlist; public: /...

A template question: Can compiler deduce template type in static method

I have the following setup: A templated class SpecialModel: template<typename A, typename B> class SpecialModel<A, B> { }; A templated Worker, working on some kind of Model: template<typename M> class Worker<M> { Worker(M& model); void work(); }; And a specialization of Worker for SpecialModel: template<typename A, typ...

How do I expire a django template cache key on recieving a signal?

In my front page template I use the cache function like this: {% cache 86400 my_posts %} {% get_latest_posts %} {% endcache %} When there is a new post I would like to expire the cache key; like this: def clear_post_cache(): cache.delete('my_posts') post_save.connect(clear_post_cache, sender=Post) My problem is that the ca...

Missing template

Hi so i have this code: <% form_tag(:action => 'find') do%> Product name: <%= text_field("cars_", "name", :size => "30") %> <input type ="submit" value="Find"/> <%end%> upon pressing the button I want it to complete the method (def find) found in the controller but its requesting the html.erb file: Template is missing Miss...

Template friend function of a template class

I was struggling with the issue described in this question (declaring a template function as a friend of a template class), and I believe the 2nd answer is what I want to do (forward declare the template function, then name a specialization as a friend). I have a question about whether a slightly different solution is actually correct o...

Problem with DataTemplate and ObjectDataProvider refresh

I have a problem with a edit templete of cell in a WPF datagrid (WPF Toolkit). The template is builded with a ComboBox and the ItemsSource of ComboBox are loaded at runtime. This is the mean code... <ObjectDataProvider x:Key="dataValuesProvider" MethodName="GetValues" /> <toolkit:DataGrid ItemsSource="{Binding Path=MyItems}"> <toolkit...

Control logic using HTML::Template

Just a couple of quick questions. If I'm writing CGI programs to create web pages via HTML::Template, then do I have to write separate tmpl files for each distinctive screen (the control logic to be in the Perl code)? Also, (and in a similar area) is it OK to put url links to the other screen CGI programs within the tmpl files? For exa...

Default template parameters with forward declaration

Is it possible to forward declare a class that uses default arguments without specifying or knowing those arguments? For example, I would like to declare a boost::ptr_list< TYPE > in a Traits class without dragging the entire Boost library into every file that includes the traits. I would like to declare namespace boost { template<class...

Delete multiple records from a table using subsonic T4 templates?

Hi, Using templates, how can I delete multiple records from a table in same Delete statement? Please advise. Thanks Pankaj ...

How do I make the "value" of the <input type="radio"> invisible?

<input type="radio" value="1" id="baby"> I'd like to keep this code like that. However, can I apply a CSS to it so that the "1" is not displayed to the user? Edit: For some reason, it is being displayed, I don't know why. I do have a CSS attached to it though. ...

Is my HTML "leaking", because it is showing abnormal behavior.

When I put this code outside of the <table>...it will work. <script type="text/javascript"> $(function(){ $("#stars-wrapper1").stars({ oneVoteOnly: true }); }); </script> <form> <div id="stars-wrapper1"> <input type="radio" name="newrate" value="1" title="Very poor" /> <input type="radio" name="newrat...

Function Template Specialization on Function Pointers

(C++) I have a sanitization function that I want to run on (traditional) pointer types only. My problem is with function templates I can get as far as limiting the function to only pointers, however because of casting rule differences between function pointers and regular pointers, I run into problems. The Sanitize() function needs ...