templates

How do I use genshi.builder to programmatically build an HTML document?

I recently discovered the genshi.builder module. It reminds me of Divmod Nevow's Stan module. How would one use genshi.builder.tag to build an HTML document with a particular doctype? Or is this even a good thing to do? If not, what is the right way? ...

Are C++ non-type parameters to (function) templates ordered?

I am hosting SpiderMonkey in a current project and would like to have template functions generate some of the simple property get/set methods, eg: template <typename TClassImpl, int32 TClassImpl::*mem> JSBool JS_DLL_CALLBACK WriteProp(JSContext* cx, JSObject* obj, jsval id, jsval* vp) { if (TClassImpl* pImpl = (TClassImpl*)::JS_GetInst...

Storing C++ template function definitions in a .CPP file

I have some template code that I would prefer to have stored in a CPP file instead of inline in the header. I know this can be done as long as you know which template types will be used. For example: .h file class foo { public: template <typename T> void do(const T& t); }; .cpp file template <typename T> void foo::do(const...

jasper reports, hiding columns at runtime

Hi, I have a Jasper report template, and I need to show/hide a column at runtime based on a particular condition. I'm using "Print when expression" to conditionally show/hide this column (and it's header) in my report. When the column is hidden, the space it would have occupied is left blank, which is not particularly attractive. I wou...

What is the recomended way to skin an entire application in WPF?

I want my WPF application to be skinnable, by applying a certain XAML template, and the changes to be application wide, even for dynamic controls or controls that aren't even in the visual/logical tree. What can I use to accomplish this type of functionality? Are there any good resources or tutorials that show how this specific task ca...

How do I include a stacktrace in my Django 500.html page?

I'm running Django 1.0 and I'm close to deploying my app. As such, I'll be changing the DEBUG setting to False. With that being said, I'd still like to include the stacktrace on my 500.html page when errors occur. By doing so, users can copy-and-paste the errors and easily email them to the developers. Any thoughts on how best to app...

Where can I find free WPF controls and control templates?

I am looking for some recommendations on good places to find libraries of controls/templates/styles for WPF. I know about the usual places like Infragistics, but it seems to me that there should be some kind of community effort by now to share nice, clean, well written controls for WPF controls. I am not big on the design side, and it w...

Template Constraints C++

In C# we can define a generic type that imposes constraints on the types that can be used as the generic parameter. The following example illustrates the usage of generic constraints: interface IFoo { } class Foo<T> where T : IFoo { } class Bar : IFoo { } class Simpson { } class Program { static void Main(string[] args) { ...

What good template language is supported in Javascript?

Templates are a pretty healthy business in established programming languages, but are there any good ones that can be processed in Javascript? By "template" I mean a document that accepts a data object as input, inserts the data into some kind of serialized markup language, and outputs the markup. Well-known examples are JSP, the origin...

xsl scope help

I have a xsl file that is grabbing variables from xml and they seem to not be able to see each other. I know it is a scope issue, I just do not know what I am doing wrong. <xsl:template match="one"> <xsl:variable name="varOne" select="@count" /> </xsl:template> <xsl:template match="two"> <xsl:if test="$varOne = 'Y'"> <xsl:value-...

Operator overloading for C++ maps

I need help understanding some C++ operator overload statements. The class is declared like this: template <class key_t, class ipdc_t> class ipdc_map_template_t : public ipdc_lockable_t { ... typedef map<key_t, ipdc_t*, less<key_t>> map_t; ... The creator of the class has created an iterator for t...

mangling __FILE__ and __LINE__ in code for quoting?

Is there a way to get the C/C++ preprocessor or a template or such to mangle/hash the __FILE__ and __LINE__ and perhaps some other external input like a build-number into a single short number that can be quoted in logs or error messages? (The intention would be to be able to reverse it (to a list of candidates if its lossy) when needed...

Compile-time type based dispatch

Following techniques from 'Modern C++ Design', I am implementing a persistence library with various compile-time optimisations. I would like the ability to dispatch a function to a templated member variable if that variable derives from a given class: template<class T, template <class> class Manager = DefaultManager> class Data { privat...

Function pointer to template class member functions

I have a templated class defined (in part) as template <class T> MyClass { public: void DoSomething(){} }; If I want to call DoSomething from another class, but be able to do this for multiple 'T' types in the same place, I am stuck for an idea as method functions pointers are uniquely constrained to the class type. Of course, each...

C++ Restrict Template Function

I wrote a sample program at http://codepad.org/ko8vVCDF that use a template function how do I retrict the template function to only use numbers? int, double etc. ...

Limiting range of value types in C++

Suppose I have a LimitedValue class which holds a value, and is parameterized on int types 'min' and 'max'. You'd use it as a container for holding values which can only be in a certain range. You could use it such: LimitedValue< float, 0, 360 > someAngle( 45.0 ); someTrigFunction( someAngle ); so that 'someTrigFunction' knows that ...

Practical Uses for the "Curiously Recurring Template Pattern"

What are some practical uses for the "Curiously Recurring Template Pattern"? The "counted class" example commonly shown just isn't a convincing example to me. ...

How do I implement Section-specific navigation in Ruby on Rails?

I have a Ruby/Rails app that has two or three main "sections". When a user visits that section, I wish to display some sub-navigation. All three sections use the same layout, so I can't "hard code" the navigation into the layout. I can think of a few different methods to do this. I guess in order to help people vote I'll put them as ans...

Learning C++ Templates

Can anyone recommend any good resources for learning C++ Templates? Many thanks. ...

Why won't Django auto-escape my <script> tags?

My Django app has a Person table, which contains the following text in a field named "details": <script>alert('Hello');</script> When I call PersonForm.details in my template, the page renders the <script> accordingly (a.k.a., an alert with the word "Hello" is displayed). I'm confused by this behavior because I always thought Djan...