John Resigs micro templating engine, question of how to handle selects?

Issue I’ve a template that looks like so: <script type=”text/html” id=”TemplateEdit”> <td> <input type=”hidden” value=”<#= item.ID #>” id=”Edit.ID” name=”Edit.ID” /> <select id=”Edit_ClientID” name=”Edit.ClientID”> <option value=”1″>test</option> <option value=”2″>test 2</option> <option value=”3″>test 3</option> </select> </td> <td> <select id=”Edit_Frequency” name=”Edit.Frequency”> <option value=”1″>Daily</option> <option

Continue reading

WPF templating/styling issue

Issue Given this piece of XAML <DockPanel> <DockPanel.Resources> <Style TargetType=”{x:Type GroupBox}”> <Setter Property=”Template”> <Setter.Value> <ControlTemplate TargetType=”{x:Type GroupBox}”> <DockPanel> <Border DockPanel.Dock=”Top”> <Border.Resources> <Style TargetType=”{x:Type TextBlock}”> <Setter Property=”Foreground” Value=”Red” /> </Style> </Border.Resources> <ContentPresenter ContentSource=”Header” /> </Border> <ContentPresenter /> </DockPanel> </ControlTemplate> </Setter.Value> </Setter>

Continue reading

Templating Html.DisplayFor() in ASP.NET MVC 2

Issue It appears that if you just use Html.DisplayFor(model => model) with no templates for a Details view, the resulting markup will look something like this: <div class=”display-label”>first name</div> <div class=”display-field”>Dan</div> <div class=”display-label”>last name</div> <div class=”display-field”>M</div> <div class=”display-label”>email</div> <div class=”display-field”>danm@fakedomain.com</div>

Continue reading

Django: using variables as array indices?

Issue I am trying to create a template that will put items in a table. Controller: items = Item.all().order(‘name’).fetch(10) template_values = {‘items’: items, ‘headers’: [‘Name’, ‘Price’, ‘Quantity’]} render(‘Views/table.html’, self, template_values) Template: <table> <tr> {% for header in headers %} <th>{{header}}</th>

Continue reading

using a loop in a template

Issue I started writing my own small scaled framework and i have gotten to the templating part of it. So far i have been able to do simple variable replacing with the following code: public function view($page, $vars) { if(!file_exists(‘system/views/’

Continue reading

ControlTemplate for ScrollBar apply only to DataGrid

Issue Hello I have a ScrollBar Template as per below – only relevant portion shown: <ControlTemplate x:Key=”VerticalScrollBar” TargetType=”{x:Type ScrollBar}”> <Grid> <Grid.RowDefinitions> <RowDefinition MaxHeight=”18″/> <RowDefinition Height=”0.00001*”/> <RowDefinition MaxHeight=”18″/> </Grid.RowDefinitions> <Rectangle Height=”35″ Width=”19″ Fill=”{StaticResource GreenTeaBrush}” Margin=”-35″ VerticalAlignment=”Top”/> <Border…. Now the Rectangle Portion:

Continue reading

Removing an item from a generic Dictionary?

Issue I have this: public static void Remove<T>(string controlID) where T: new() { Logger.InfoFormat(“Removing control {0}”, controlID); T states = RadControlStates.GetStates<T>(); //Not correct. (states as SerializableDictionary<string, object>).Remove(controlID); RadControlStates.SetStates<T>(states); } states will always be a SerializableDictionary with string keys. The values’

Continue reading

How can I change a control's style just for one part of my app in WPF when the control's Type has a global Style?

Issue I have styled my Menu/ContextMenu/MenuItem controls in App.xaml so that those styles apply to all my app. defined like this (e.g. with the MenuItem): <Style TargetType=”{x:Type MenuItem}”> <Setter Property=”SnapsToDevicePixels” Value=”true”/> <Setter Property=”OverridesDefaultStyle” Value=”True”/> <!– more setters –> </Style> this

Continue reading

jade outputs relative links

Issue I’m starting to play with node, express and jade and when I do this a(href=”http:/www.example.com/” + variable) variable I get a relative link, say <a href=”http://127.0.0.1:3000/www.example.com/mytext”>mytext</a> Instead of the absolute link. I’m guessing I’m doing something wrong with the

Continue reading

A better way to do replacement tags in c#?

Issue I need a better way to do this: Regex.Replace(Regex.Replace(Regex.Replace(Regex.Replace(Regex.Replace(textMessage.Trim(), “{birthday}”, person.Birthday, RegexOptions.None), “{phone}”, person.MobilePhone, RegexOptions.None), “{email}”, person.Email, RegexOptions.None), “{lastname}”, person.LastName, RegexOptions.None), “{firstname}”, person.FirstName, RegexOptions.None) Solution textMessage.Trim() .Replace(“{birthday}”,person.Birthday) .Replace(“{phone}”,person.Phone) … Answered By – Reza ArabQaeni Answer Checked By – Gilberto

Continue reading

YUI 3 html templating

Issue Is there any way to create HTML markup in YUI like: <div id={DivId}> <p class={pClass}> <span class={spanClass}> {Content} </span> </p> </div> Solution If I understand your question correctly, Y.substitute might be worth looking at. If you haven’t seen it,

Continue reading

JQuery Pure Template

Issue I cant figure out whats wrong. Its working when i tried to refresh only topics but it doesnt works when tried to refresh topics and page-links. ie. topics table’s refreshing, and ‘pagelinks’ disappearing, i thought pure cannot reach –

Continue reading

PHP/HTML: Code reuse

Issue How does Stackoverflow reuse their code, especially the header and footer? So, basically when i click on ‘Tags’ only the content changes, not the header and footer. What are the best pratises? A link to a simple tutorial would

Continue reading

ListView DataTemplate, ControlTemplate and Style

Issue Still learning WPF….thanks for any help. Is there any way to Refactor this: <ListBox Name=”lbEvents” VerticalAlignment=”Stretch” SelectionMode=”Multiple” Loaded=”lbCenterEvents_Loaded” HorizontalAlignment=”Stretch” BorderBrush=”Transparent” Background=”Transparent” SelectionChanged=”lbCenterEvents_SelectionChanged” ItemContainerStyle=”{StaticResource KioskCheckboxListItemContainer}”> <ListBox.Resources> <SolidColorBrush x:Key=”{x:Static SystemColors.HighlightBrushKey}” Color=”Transparent” /> <SolidColorBrush x:Key=”{x:Static SystemColors.HighlightTextBrushKey}” Color=”Black” /> <SolidColorBrush x:Key=”{x:Static SystemColors.ControlBrushKey}” Color=”Transparent”

Continue reading

Underscore Templating – Partials (with RequireJS)

Issue I am using the tpl! plugin for RequireJS to import and compile my templates into my application – similar to the text! plugin: define([ “tpl!../templates/newsfeed.html”, “tpl!../templates/friends.html”, “tpl!../templates/tag.html”, “tpl!../templates/tags.html”, ], function (renderNewsfeed, renderFriends, renderTag, renderTags) { … }); This all

Continue reading

templating in php using tpl files

Issue $data = {include “header.tpl”}{include “footer.tpl”}; private function get_tpl_includes($data){ $this->includes = preg_match_all(‘/{include \”[^}]\”*}/’, $data, $this->includes); foreach($this->includes as $include){ $tpl_file = $this->dir . str_replace($this->dir, “”, $include[0]); $html_include = file_get_contents($tpl_file) or die(“tp3”); //Get the content of the included html $pattern = ‘{include

Continue reading

Using PHP code in PHP code?

Issue I have the following code in PHP: <?php if (function_exists(“insert_audio_player”)) {insert_audio_player(“[audio:|titles=]”} ?> Which renders an audio player to my page in WordPress. I need to call a custom field inside this code. My custom field code is also coded

Continue reading

How can I convert erb to html?

Issue Imagine in rails I have @template that is an instance of ActionTemplate::View. Question is: How can I convert @template whose @template.source is <%= “hello from erb” %> to hello from erb?? thanks Solution Try this… ERB.new(@template.source).result ERB#new Answered By

Continue reading

Interpolate Twig variable/attribute inside value of another Twig attribute definition

Issue Take the following example structure: {% set paths = { … ‘js’: { … ‘jquery’: { ‘version’: ‘1.7.2’, ‘cdn’: ‘https://ajax.googleapis.com/ajax/libs/jquery/{{paths.js.jquery.version}}/jquery.min.js’, ‘fallback’: …. } } } %} To access, I would normally use something like: <script src="{{paths.js.jquery.cdn}}"></script> The problem: The

Continue reading