templates

Get list of {} templates from String [PHP]

Hi, I want to get the template words in a string. Template in the sense of words in {} inside a string. I am adding here a code to explain what I want exactly. $string = "Hi {username}, Here is your {password}"; function get_template_variables($string) { .... .... return array(); } $result = get_template_variables($strin...

What is POI and what does it mean?

What is POI? I have seen this term being used several times in context of C++ Templates. What does it mean? ...

SQL templating engine to mix SQL with dynamic language? (similar to Ruby's erb)

Has anyone comes across a SQL templating engine which allows one to mix SQL with a dynamic language like Ruby or Python? I'm looking for something similar to Ruby erb templates. For example, in Ruby on Rails you can have various templates for a view: customers.html.erb (html + ruby) customers.js.erb (javascript + ruby) Though I want s...

How do you initialize a static templated container?

Hi, I'm trying to figure out the correct way of initializing a static container variable whose template value is a private inner class. Here's a toy example #include <vector> using namespace std; template <class myType> class Foo { private: class Bar { int x; }; static vector<Bar*> bars; }; template <class myT...

Generic structs in unions

I'm trying to make a generic vector class. While I can do something like this: struct vector3 { union { struct { float x; float y; float z; }; float v[3]; }; }; I cannot do this: template<int N, typename S, typename T = double> class vec { union { T data[N]; S; }; }; struct...

Pylons + Mako -- Access POST data from templates

How can I access my request.params post data from my Mako template with Pylons? ...

Symfony 1.4 - set template for component / partial

Hi everyone! I'm trying to set a different template for components/partials, but nothing works. Here is the problem, the pattern is in another folder, not a folder module. Can I somehow set the template for a component/partial from another folder? ...

how to make a xaml control with different view modes

I'm trying to learn how to separate a view from its associated viewmodel, while making the view have as little or no code-behind as possible. my control has a textblock when the object is in a display mode, and a textbox when the user wants to edit that field. In both cases, these controls must bind to the same string in the modelview,...

c++ member function specialisation of a class that has a template as a parameter

I am working on a template class Array, which accepts another template TRAITS as a parameter. template <typename BASE, typename STRUCT> class Traits { public: typedef BASE BaseType; typedef STRUCT Struct; // .. More here }; template <class TRAITS> class Array { public: typedef TRAI...

EventTrigger with Setter in WPF?

I have a normal Button and TextBox in a WPF-Window and I want a Template for the Button with a EventTrigger that listens to Button.Click and then sets a boolean-property of the TextBox. No code-behind. Something like this: <ControlTemplate.Triggers> <EventTrigger SourceName="MyButton" RoutedEvent="Button.Click"> <Setter TargetNam...

MVC2 Editor templates not using datetime format

Following on from an earlier question, I'm having problems using an Editor template for datetime fields, below is the code for the editor template (called "EditDateTime"). <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<System.DateTime?>" %> <%= Html.TextBox("", (Model.HasValue ? Model.Value.Date.ToString("dd/MMM/yyy...

Multiple ContentProviders in one UserControl

Hi Silverlighters. I have problem where I'd like to design a UserControl containing two ContentControls. Imagine the old fashioned explorer that has a treeview on the left and a list on the right. I need the users of my control to be able to add their own controls to each ContentControl - say the left and the right. Unfortunately the Con...

Python Metaclass to Parametrize Inheritance

I've read some tutorials on Python metaclasses. I've never used one before, but I need one for something relatively simple and all the tutorials seem geared towards much more complex use cases. I basically want to create a template class that has some pre-specified body, but takes its base class as a parameter. Since I got the idea fr...

Using a class that inherits a template class as a constructor parameter in the template class?

Say I have the following: template <class T> class Foo {}; and a descendant class, class Bar : public Foo<some_typename>{}; How would I go about passing Bar to Foo's constructor without Foo.h including Bar.h, if that is even possible? ...

Multiple types in one specialized D template

Say I have to deal ushort and uint some way, but string differently. So guess I need one specialized template for string and other to both ushort and uint. Is it? // for most void func(T)(T var) { ... } // for uint and ushort void func(T: uint, ushort)(T var) { ... } That is the idea, although the code can't compile. It's valid or ...

Templated function being reported as "undefined reference" during compilation

These are my files: --------[ c.hpp ]-------- #ifndef _C #define _C #include<iostream> class C { public: template<class CARTYPE> void call(CARTYPE& c); }; #endif --------[ c.cpp ]-------- #include "c.hpp" template<class CARTYPE> void C::call(CARTYPE& c) { //make use of c somewhere here std::cout<<"Car"<<std::endl; } ...

LaTeX template for technical reference manual?

Hello, I'm looking to use LaTeX for my technical documentation needs (such as reference manuals, user guides, etc). Could I use your template to quickly get started in order to avoid being overwhelming by the LaTeX world... tons of packages and control sequences. At minimum, I will need Table of Contents, figures, tables, Index, Glossar...

How to forward declare a template class?

Hi, I tried this : #ifndef __TEST__ #define __TEST__ namespace std { template<typename T> class list; } template<typename T> void Pop(std::list<T> * l) { while(!l->empty()) l->pop(); } #endif and used that function in my main. I get errors. Of course, I know that there are more template params for std::list...

Confused about implicit template instantiation

This is the statement from the C++03 standard, §14.7.1p5: If the overload resolution process can determine the correct function to call without instantiating a class template definition, it is unspecified whether that instantiation actually takes place. [Example: template <class T> struct S { operator int()...

num_get facet and stringstream conversion to boolean - fails with initialised boolean?

I have inherited a template to convert a string to a numerical value, and want to apply it to convert to boolean. I am not very experienced with the stringstream and locale classes. I do seem to be getting some odd behaviour, and I am wondering if someone could please explain it to me? template<typename T> T convertFromString( const ...