templates

How to put comments on .html.tpl file

I am trying to do some commenting on a .html.tpl file I'm maintaining using <!-- --> but it would return syntax error. How do you put comment on such files? ...

Getting template text from FreeMarker in Struts2 app

I would like to generate email inside a Struts2 application, using Freemarker. As I am also using Freemarker for my view, I would like to "reuse" the same config. There is already a similar question for doing the same thing with Spring. http://stackoverflow.com/questions/230763/getting-template-text-from-freemarker-in-spring-app I am n...

C++ Template - Multiple types

consider the following template class. template <class T> class MyClass { void MyFunc(); } template <class T> void MyClass<T>::MyFunc() { //...implementation goes here } I need to add another function MyFunc2 which accepts an additional Template arg T2 i.e template <class T> class MyClass { void MyFunc(); template <clas...

typedef for enum from template base class

Followup on an answer from last night - I was hoping more comments would answer this for me but no dice. Is there a way to achieve this without inheritance that does not require the cumbersome usage in the penultimate line of code below, which writes the value to cout? struct A { enum E { X, Y, Z }; }; template <class ...

Advantages of using boost::mpl::bool_ instead of a const bool

I am confused about the advantages of using the the bool_<true> and bool_<false> types against simply using const bools in the context of template metaprogramming. The boost::mpl library clearly prefers the first approach, and defines helper functions like and_, or_ to help manage such bool_. Conditional metafunctions like if_...

ASP NET mvc 2 Template for EditorFor and DisplayFor

I would like to control or customise the output generated by DisplayFor and EditorFor so it doesn't render the default html css tags for example: ....... I would like this to be for all views not just a type or system type? And what is the simplest solution? Any help would be appreciated. ...

Why do I get missing symbols for an explicit template specialization in a static library?

If I compile the following code: // // g++ static.cpp -o static.o // ar rcs libstatic.a static.o // #include <iostream> template < typename T > struct TemplatedClass { void Test( T value ) { std::cout << "Foobar was: " << value << std::endl; } }; template struct TemplatedClass < long >; I get a static library and if I run ...

C++ template friend operator overloading

What is wrong with my code? template<int E, int F> class Float { friend Float<E, F> operator+ (const Float<E, F> &lhs, const Float<E, F> &rhs); }; G++ just keeps warning: float.h:7: warning: friend declaration ‘Float<E, F> operator+(const Float<E, F>&, const Float<E, F>&)’ declares a non-template function float.h:7: warning: (if th...

About C++ template and operators

After some trial and a lot of error, I have come to find out that it is not very useful to template operators. As an Example: class TemplateClass { //Generalized template template<TType> TType& operator[](const std::string& key) { return TType; } //Specialized template for int template<> int& operator[]<int>(const st...

Potential pitfalls with my new markup language?

Something that's really bothered me about XHTML, and XML in general is why it's necessary to indicate what tag you're closing. Things like <b>bold <i>bold and italic</b> just italic</i> aren't legal anyways. Thus I think using {} makes more sense. Anyway, here's what I came up with: doctype; html { head { title "my webpage" javascript...

ListView - Show LayoutTemplate on empty data source

For a shopping cart page, the list of items is displayed in a html table. I use a ListView for that and it works great. When the cart is empty, the text 'This cart is empty' appears. But it only renders the code in the EmptyDataTemplate. My goal is to display the table headers ('delete', 'product', 'quantity', etc.) without repeating th...

Why NULL is converted to string*?

Hello all, I saw the following code: class NullClass { public: template<class T> operator T*() const { return 0; } }; const NullClass NULL; void f(int x); void f(string *p); f(NULL); // converts NULL to string*, then calls f(string*) Q1> I have problems to understand the following statement template<class T> operator T*() con...

How do I render a jQuery.tmpl Template to a String?

The documentation for jquery.tmpl uses .appendTo to insert the template into the DOM during the rendering process: $.tmpl( myTemplate, myData ).appendTo( "#target" ); I am attempting to convert an existing app from another templating engine, and my code needs to render a template into a string first before it is added to the DOM. Is t...

how to automate template typename specification with CLASSNAME<typename>(argument);

I'm creating a stat editor for some objects within a game world. Rather than have multiple edit menus for each object type, I just have one menu, and pass in a list/vector of stat-edit-objects which contain a pointer to the stat being edited, and the functions to do the work. struct StatEditObjPureBase { std::vector<std::string> rep...

jQuery: Templates. Must be contained in script block?

As a JS developer, I always keep my design layer separate from my business layer. Meaning, HTML is always alone, CSS and JavaScript files are external and included. Now, in the case of jQuery Templates, a declared template must apparently live within a script block of the page. How in the world are you supposed to keep all of your busin...

GCC 4.2 Template strange error.

Hello, i have the following code compiled with GCC 4.2 / XCode. template <typename T> class irrProcessBufferAllocator { public: T* allocate(size_t cnt) { return allocProcessBufferOfType<T>(cnt); } void deallocate(T* ptr) { if (ptr) { releaseProcessBuffer(ptr); } } ...

Templates :Function template specializations:Template argument deduction: -->can any one tell some more examples for this statement?

This is the statement from ISO C++ Standard 14.8.2.4 / 3rd :Deducing template arguments from a type A given type P can be composed from a number of other types, templates, and non-type values: — A function type includes the types of each of the function parameters and the return type. — A pointer to member type inc...

Using a pointer to a function as a template parameter

(C++) I've got a number of Entry classes, and got BaseProcessor interface which incapsulates Entry processing logic. (see code below) The Entry doesn't provide operator<(). The BaseProcessor provides a pointer to less(Entry, Entry) function which is specific for particular BaseProcessor implementation. I can use the function pointer to...

Enumerated classes

I have happened upon the following pattern, and wondered if there is a name for it? An enum defines the concrete classes: enum Fruits{ eApple, eBanana }; And a templated struct provides the interface: template< Fruit T > struct SomeFruit { void eatIt() { // assert failure }; }; We can then implement the concrete classes thus: ...

class containing a generic type of a child

Is there any possible way that a generic type can be used to contain a child of a base class. From the assignment given to me, I am to create something similar to the following in structure. template <class T> class Fruit { private: int count; int location_id; T type; public: virtual void displayInfo(); }; class Ap...