templates

How to resolve "Something Went wrong" error in ruby on rails ?

Hi, I am using Ubuntu 9.04 I just installed ruby and rails in my system and the webrick server seems to have been installed without any errors. I created a "demo" rails app and created a controller 'say'. Then i created a view template 'hello.rhtml' I started the server and entered http://localhost:3000/say/hello in my browser. But t...

Template specialization for enum

Is it possible to specialize a templatized method for enums? Something like (the invalid code below): template <typename T> void f(T value); template <> void f<enum T>(T value); In the case it's not possible, then supposing I have specializations for a number of types, like int, unsigned int, long long, unsigned long long, etc, then...

In Django, how can I embed something in CSS?

background: url({{ MEDIA_URL }}/bg.jpg); That does not work, because this Django template function only works in .html! ...

404 Error messages in django

I have a project that I am working on in django. There are a lot of instances where I: raise Http404("this is an error") and it creates a nice 404 page for me with the error message "this is an error" written on it. I now want to create a custom error page and have it still display the message, but I can't figure out how. I'm sure it'...

blogger layout syntax question

I know this on the javascript programming if(a==b){}else{} same code on the blogger blog template syntax <b:if cond='a==b'> <b:else/> </b:if> I need, how to do following on the blogger if(a==b) || (c==a) how to create multi conditional expression ? data:blog.url.substring(40) how to subtract data:blog.url string. ? data:blog.ur...

Automate pimpl'ing of C++ classes -- is there an easy way?

Pimpl's are a source of boilerplate in a lot of C++ code. They seem like the kind of thing that a combination of macros, templates, and maybe a little external tool help could solve, but I'm not sure what the easiest way would be. I've seen templates that help do some of the lifting but not much -- you still end up needing to write forwa...

Why don't all XSLT templates get executed at once?

Refer to: http://stackoverflow.com/questions/1613454/retrieving-one-element-and-filter-by-another In the above linked posting, I don't understand why the two template blocks don't get executed upon in the incoming XML at the same time. As far I can can see, the XSL risks the second template executing for every Document element whether i...

Is it possible to have a non-template class subclass a template class?

I have a template class defined like so: template <class T> class Command { public: virtual T HandleSuccess(std::string response) = 0; virtual std::string FullCommand() const = 0; // ... other methods here ... }; Will C++ allow me to create a non-template subclass of a template class? What I mean is can I do something like...

How come when I change the height of this div, it "overlaps" the div below it?

How do i make it so that as the first div expands...the lower div will automatically go lower, due to the height of the first div now is larger? Is this display? Or Position? ...

How to add new project template to Delphi

I remember doing this in Delphi 7, but I don't remember how, or it is different in the new Delphi IDE. But how do I add a new template to the items gallery? So then it will show up under the File / New menu. ...

operator= (T *r) in nested templates

Hi everybody. I have a problem concerning nested templates and the overriding of the assignment operator. Say i want to have a refcounting class template _reference. This _reference for now simply holds a pointer to the ref-counted object. The problem now is that this all works fine, as long as im doing this with simple classes or str...

How to write `is_complete` template?

After answering this question I was trying to find is_complete template in Boost library and I realized that there is no such template in Boost.TypeTraits. Why there is no such template in Boost library? How it should look like? //! Check whether type complete template<typename T> struct is_complete { static const bool value = ( si...

How can I pass an arithmetic operator to a template?

I want to somehow merge templates like these into one: template <class Result, class T1, class T2> class StupidAdd { public: T1 _a; T2 _b; StupidAdd(T1 a, T2 b):_a(a),_b(b) {} Result operator()() { return _a+_b; } }; template <class Result, class T1, class T2> class StupidSub { public: T1 _a; T2 _b; StupidSub(T1 a, ...

C++ template specialization without default function

Hello, I have the following code that compiles and works well: template<typename T> T GetGlobal(const char *name); template<> int GetGlobal<int>(const char *name); template<> double GetGlobal<double>(const char *name); However I want to remove the "default" function. That is, I want to make all calls to GetGlobal<t> where 't' is not...

PHP Smarty - Get a list of all the variables in a template?

I'm using Smarty and PHP. If I have a template (either as a file or as a string), is there some way to get smarty to parse that file/string and return an array with all the smarty variables in that template? e.g.: I want something like this: $mystring = "Hello {$name}. How are you on this fine {$dayofweek} morning"; $vars = $smarty->ma...

Ambiguous overload on template operators

I am working on two wrapper classes that define real and complex data types. Each class defines overloaded constructors, as well as the four arithmetic operators +,-,*,/ and five assignment operators =,+= etc. In order to avoid repeating code, I was thinking of using template functions when the left- and right-hand-side arguments of an o...

C++ template recursion - how to solve ?

Im stuck again with templates. say, i want to implement a guicell - system. each guicell can contain a number of child-guicells. so far, so tree-structure. in std-c++ i would go for sthg. like: template <typename T> class tree { public: void add (T *o) { _m_children.push_back (o); } void remove (T *o) { ... }; list<T*>...

c++ class with templates compilation error

I'm not an experienced C++ programmer and I'm having problems compiling. I've got a Heap class that uses a template: template <class T> class Heap { public: Heap(const vector<T>& values); private: vector<T> d; // etc. }; And then in a separate implementation file: template <class T> Heap<T>::Heap(const vector<T>& val...

PHP equivalent for RoR template partials/collections

Hi, I'm trying to figure out the most efficient way to implement RoR-style partials/collections for a PHP template class that I'm writing. For those who aren't familiar with rails, I want to iterate over a template fragment (say a table row or list item) located in a separate file. I want to do this without resorting to eval or placing a...

Performance: Templates in a Database or a File?

What is the fastest way to store templates? In a database (SQL Server) or a file? Those template can be from 1KB to ~15KB (usually 1-3KB). After reading the template, I'm parsing it with Regex to HTML. I've <div>[Block Parameter="Value" Parameters2="SomeValue" ...]</div> for example, so please consider that. Thanks. ...