templates

PHP Templating

I'm writing a simple templating layer in PHP but I've got myself a little stuck. Here's how it works at the moment: Firstly I use fetch_template to load the template contents from the database - this works (and I collect all the templates at startup if you're interested). I use PHP variables in my template code and in the logic - e.g.:...

C++: Using operator of two intrinsic types as a function object

I have a vector-like class that contains an array of objects of type "T", and I want to implement 4 arithmetic operators, which will apply the operation on each item: // Constructors and other functions are omitted for brevity. template<class T, unsigned int D> class Vector { public: // Add a value to each item: naive implementatio...

Regex match question

In javascript, I've got a block of HTML like this: <h2>{title}</h2> <p><a href="{url}">{content}</a></p> And I'm trying use regex "match" to spit out an array of all the {item}'s. So my output should look like: ['title', 'url', 'content'] I've gotten as far as: var pattern = new RegExp("\{[a-zA-Z]+\}+"); var match = pattern.exec("...

Extract C++ template parameters

Although I'm doubtful, I'm curious as to whether it's possible to extract primitive-type template parameters from an existing type, perhaps using RTTI. For example: typedef std::bitset<16> WordSet; Would it be possible to extract the number 16 in the above code without hard-coding it elsewhere? Compiler specific implementations are w...

Determine if Type is a pointer in a template function

If I have a template function, for example like this: template<typename T> void func(const std::vector<T>& v) Is there any way I can determine within the function whether T is a pointer, or would I have to use another template function for this, ie: template<typename T> void func(const std::vector<T*>& v) Thanks ...

WPF: Can I restyle a checkbox template, so that the checkindicator is a red cross instead

I can´t find a way to restyle the IsChecked indicator of a checkbox. As I can see from the checkbox template there´s no possibilities to restyle the indicator, just the "box" of the checkbox. Does anyone knows if it´s possibly to restyle the IsChecked indicator? ...

How to check if a variable exists in a FreeMarker template?

Hi, I have a Freemarker template which contains a bunch of placeholders for which values are supplied when the template is processed. I want to conditionally include part of the template if the userName variable is supplied, something like: [#if_exists userName] Hi ${userName}, How are you? [/#if_exists] However, the FreeMarker man...

where is my ActiveX DLL project template in VS 2005?

In VB6, ActiveX DLL is listed as a project template but in VS 2005+ there is no such thing. Where is my good old ActiveX DLL template? Many thanks in advance. ...

Wpf custom control template - relative font size

I am creating a custom WPF control that let's say for simplicity sake has a vertical stack panel with a "title" TextBlock, followed by a ContentPresenter. I want the font size for the "title" to be 5 Points LARGER than the size used in the content, which is inherited by whatever container the user places this control in. How can I speci...

Providing an iterator for the first element of a container of pairs

I have a container filled with pairs. I want to iterate in it using the STL generic algorithms (in my case it would be inner_product, but consider it as a generic problem). The algorithm I am using expects iterators first and last. Can I provide special iterators first and last that will iterate not on the pairs but on the first element ...

How to declare/define a class with template template parameters without using an extra template parameter

Consider the following use of template template parameters... #include <iostream> template <typename X> class A { X _t; public: A(X t) :_t(t) { } X GetValue() { return _t; } }; template <typename T, template <typename T> class C > class B { C<T> _c; public: B(T t) :_c(t) ...

C++ templates and inheritance

My C++ framework has Buttons. A Button derives from Control. So a function accepting a Control can take a Button as its argument. So far so good. I also have List<T>. However, List<Button> doesn't derive from List<Control>, which means a function accepting a list of Controls can't take a list of Buttons as its argument. This is unfortun...

Possible to modify the C# that Linq To SQL generates?

It would be really handy to be able to somehow say that certain properties in the generated entity classes should, for example, be decorated by (say) validation attributes (as well as Linq To SQL column attributes). Is it a T4 template someplace? Or are there other ways to skin the cat? ...

How to use Java to edit a template document (form letter) from a file?

I'm playing with Java for the first time and need to be able to replace some words in a template. example template - "Dear PUT_THEIR_NAME_HERE, I'm contacting you ..... bla bla bla Regards, PUT_COMPANY_NAME_HERE" What's the simplest way (preferably using the standard library) to make a copy of this template file and add the correct...

How best to switch from template mess to clean classes architecture (C++)?

Assuming a largish template library with around 100 files containing around 100 templates with overall more than 200,000 lines of code. Some of the templates use multiple inheritance to make the usage of the library itself rather simple (i.e. inherit from some base templates and only having to implement certain business rules). All that...

Defining templates for common look and feel pragmatically

I have a new project which simply put, is an attempt to formalize the look and feel of all of our departmental pages. I Googled around and found many tutorials which discussed the pros and cons of several techniques. And from what I've been reading, the thing I'm ooking for is controls. Basically, I want a common header and footer. <hea...

Can you do "math" within WPF Styles that are data-bound

I have a button control style and I want to change the padding from whatever the data-bound version is to adjust for a glyph that needs a 2 pixel offset. I'll use SimpleButton from SimpleStyles.xaml as an example (... shows where the trigger code was removed for conciseness): <Style x:Key="SimpleButton" TargetType="{x:Type Button}" Bas...

Can't make my slice from the HTML link repeat to extend

I have attempted to insert an html image withing an email (Outlook) to save as a template. I am finding that there is a slice that should repeat is not working correctly (to have the color extend to where the text ends). Is there someone who may be able to assist me in this matter? Below is the coding that I am using. <HTML> <HEAD>...

Current view file in Rails helper method

Is there some way to determine what file currently is being rendered by Rails (2.2) in a helper method. An example result would be "/sessions/new.html.erb" or something similar. I am trying to write a helper function that does something based on the file name that is being rendered, so I need a reliable way to obtain this information. I...

What is the best practice for creating RE-USABLE control templates in Silverlight.

What is the best practice for creating re-usable control templates. For example. I want to start with the standard checkbox and modify its template for re-use accross multiple future projects. I understand how to modify the template in Blend, but it always wants to save the template to App.xaml of the current project or to the parent...