templates

Templates using php?

Whats the best way to create my own template engine using php, to transfer html templates into actual websites, and replacing the placeholders with the actual data... well, let me solve my own question... class Template{ $private $output = ''; public function Load_Template($template){ ob_start(); include($template); $this-...

PHP Eval that evaluates HTML & PHP

Hi all, I'm messing around with templating and I've run into a situation where I need to echo to the browser a template that contains html & php. How do I evaluate the PHP and send it to the browser? So here's an example (main.php): <div id = "container"> <div id="head"> <?php if ($id > 10): ?> <H3>Greater than 10!</H3> <...

How to pass parameters to PHP template rendered with 'include'?

Hi guys, need your help with PHP templating. I'm new to PHP (I'm coming from Perl+Embperl). Anyway, my problem is simple: I have a small template to render some item, let it be a blog post. The only way i know to use this template is to use 'include' directive. I want to call this template inside a loop going thru all the relevant blog...

How to implement smart pointer which can be instantiated with void?

Some smart pointer templates, such as boost::shared_ptr, may be instantiated with void to hold an arbitrary object: http://www.boost.org/doc/libs/1_39_0/libs/smart_ptr/sp_techniques.html#pvoid Below is a minimal scoped_ptr implementation. When instantiated with void, the compiler complains about an illegal "reference to void" being for...

Multiplying and adding images with CImg In C++

Hello I am trying to find C in the following function in CImg C=B*L+(1-B)S Where C, L and S are all RGB images of the same size (and B is a single channel grayscale matte) I cannot figure out how to loop over the pixels. I've seen code like: cimg_forXYZ(S,x,y,z) {... } But I have never see than kind of syntax before, could it be ...

How do I persuade VS2008 to run .tt template files?

Following the words-of-one-syllable walkthrough should get my demo app working, right? But I fell down twice so far and I'm only up to step 4 in the 5 step process :( 1 Create a new project in Visual Studio 2008 Done that, yayy! 2 Add a connection string to your Web/App.config, give it a name, and point it to a valid database Done ...

c++ template problem in cross-platform code

I'm having some trouble getting this code to compile on Linux but it works perfectly in Windows. Windows compiler: Visual Studio 2005 Linux compiler: gcc version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4) class DoSomething { public: template <class DataType> bool Execute() { //do something here } }; template <cla...

PHPTAL and nested templates. Possible?

I've been playing around with PHPTAL for the last couple of days. Overall I really like it. It's been much easier to get into than most others I've looked into. I am having one particular problem, though. Here's the issue. I am trying to nest two templates. Let's say InnerClass has this template: <div>Hello World!</div> OuterClass ha...

Visual Studio Intelligent Project Templates

I need to construct a Visual Studio project template that has a certain amount of intelligence. I've discovered a way to get Visual Studio to call my custom code upon creation of a new project from my template, the custom code displays a dialog box and gathers information from the user, then defines additional substitutions that the proj...

org.apache.velocity.exception.ResourceNotFoundException

Hi All, i am using velocity engine template for mailing in struts1 and hibernate configuration. i got error : org.apache.velocity.exception.ResourceNotFoundException while i try to send mail. i have included velocity1.5.jar, mail.jar, activation.jar, smtp.jar. i include the velocity template path here String velocityTemplate = "mail...

ASP.NET MVC with Custom/legacy template management system

Hi -- We have a legacy template management system, which basically returns html files from the disk based upon supplied input values. For example: TStoreMgr.GetTemplate(contextName, loc, "header.template") We want to move to ASP.NET MVC, but stay with existing template management system. Is it something possible? If so, is it worth us...

template specialization of template class

Hello, I want to specialize following member function: class foo { template<typename T> T get() const; }; To other class bar that depends on templates as well. For example, I would like bar to be std::pair with some template parameters, something like that: template<> std::pair<T1,T2> foo::get() const { T1 x=...; T2...

Policy based design decisions

Hello, I have a class called Device that accepts two policies as far as I can see: StatePolicy and BehaviorPolicy. The StatePolicy holds and manages the state of the device. The BehaviorPolicy wraps the device driver that is written in C or C++. Now I have two questions: How to coordinate between the state and the behavior policies? ...

Forward-declaring template pointer

Do I really need three statements, i.e. like this class A; template<class _T> class B; typedef B<A> C; to forward-declare a pointer of template type C, like so: C* c = 0; I was hoping to be able to conceal the classes A and B in my forward-declaration, is that even possible? ...

Bit twiddling: find next power of two with templates in c++

This is a follow-up to my general question: bit-twiddling-find-next-power-of-two I have now created the following template function: template <typename T> T nextPowerOfTwo(T n) { std::size_t k=1; n--; do { n |= n >> k ; k <<=1; } while (k < sizeof(T)*8) return ++n; } 2 Questions: Specifying ...

sizeof() And Template Argument In ctor / Non-ctor Function

I hit a snag today... I wanted to define a small templated helper class: template<class T> CMyClass { public : CMyClass() { size_t iSize = sizeof(T); } // Allowed. size_t GetElementSize() const { return sizeof(T); } // C2027. }; and of course, it wouldn't compile (C2027). My question was, is it possible to get the size of t...

Weird behavior of template arguments in Visual C++ ?

I tried this example from "C++ Template - The Complete Guide" by Nicolai M. Josuttis #include <iostream> using namespace std; template< typename T > class List { }; typedef enum { RED, GREEN, BLUE } *color_ptr; int main() { struct Local { int x; }; List< Local > l; // error : local type in template argument ...

Django: Use different templates on an inline when edit or add

Let's say I want to use a different template for the add page but not the edit. What would be the best way to accomplish that? I was thinking either subclassing add_view or change_view, or alternatively maybe subclass some InlineModelAdmin method. What's your guys take on this? Thanks. ...

Determine whether a class has a function

Using a trick (described by Olivier Langlois), I can determine whether a class has a type defined: template<typename T> struct hasType { template<typename C> static char test( typename C::Type ); template<typename C> static char* test(...); enum{ Value= sizeof(test<T>(0))==1 }; }; I can also determine whether a class has a...

Which extension should I use for view templates in Rails?

As far as I know, .rhtml is deprecated in Rails 2. In some guides there is only .erb, but both RubyMine and NetBeans IDE generate .html.erb and I've also seen it many people using. I've tested both and they seem to work fine without any errors or warnings, but which one is correct? .erb or .html.erb ...