Sponsored Content
Top Forums Shell Programming and Scripting automate editing of a template Post 302667021 by jim mcnamara on Thursday 5th of July 2012 12:55:16 PM
Old 07-05-2012
Code:
awk 'FILENAME=="file1" {arr[FNR]=$0; next}
       FILENAME=="file2" {sub("@tag@", arr[FNR], $0);  print}' file1  file2 > newfile

This User Gave Thanks to jim mcnamara For This Post:
 

6 More Discussions You Might Find Interesting

1. Programming

About template constraints

Hi, i have class template, 1)can i override the copy constructor 2)can we have virtual function in class template if not plz tel why? I tried , compile error comes for me... Thanks Sarwan (0 Replies)
Discussion started by: sarwan
0 Replies

2. Programming

Template problem ...

Hi all, Need your help. I am doing a simple template program , getting some error ... here is the code #include <iostream> #include <stdio.h> #include <stdlib.h> #include<iostream> #include<string> #include <sstream> using namespace std; class Base_class { public: Base_class(){... (1 Reply)
Discussion started by: amartya_sock
1 Replies

3. Shell Programming and Scripting

Help with template like solution

hi experts, i'm trying to do this: file1 is a template. might have kinds of 'funny' characters. sample: <body> <form> <p><input type="text" name="abc"/></p> &nbsp; <p><my_content></p> </form> </body> file2 is a file that contains lots of text. this might be very big. might have... (2 Replies)
Discussion started by: xjohnu
2 Replies

4. Programming

C++ template error

I get some compiling errors about template instantiation :wall: , but I can't find where the syntax errors happens. Can some help me? template<typename Type> class SingleList; template<typename Type> class SingleListNode{ private: friend class SingleList<Type>; SingleListNode() :... (1 Reply)
Discussion started by: 915086731
1 Replies

5. Programming

Calling template at once

Hello Again, I am just wanted to know if we can call the Template using "require_once" at PHP? Any views around happy to discuss. Thanks in Advance (2 Replies)
Discussion started by: AimyThomas
2 Replies

6. Shell Programming and Scripting

Convert vi editing to text editing

Dear Guru's I'm using Putty and want to edit a file. I know we generally use vi editor to do it. As I'm not good in using vi editor, I want to convert the vi into something like text pad. Is there any option in Putty to do the same ? Thanks for your response. Srini (6 Replies)
Discussion started by: thummi9090
6 Replies
Text::MicroTemplate(3pm)				User Contributed Perl Documentation				  Text::MicroTemplate(3pm)

NAME
Text::MicroTemplate - Micro template engine with Perl5 language SYNOPSIS
use Text::MicroTemplate qw(:all); # compile template, and render $renderer = build_mt('hello, <?= $_[0] ?>'); $html = $renderer->('John')->as_string; # or in one line $html = render_mt('hello, <?= $_[0] ?>', 'John')->as_string; # complex form $mt = Text::MicroTemplate->new( template => 'hello, <?= $query->param('user') ?>', ); $code = $mt->code; $renderer = eval << "..." or die $@; sub { my $query = shift; $code->(); } ... $html = $renderer->(CGI->new)->as_string; DESCRIPTION
Text::MicroTemplate is a standalone, fast, intelligent, extensible template engine with following features. standalone Text::MicroTemplate does not rely on other CPAN modules. fast Based on Mojo::Template, expressions in the template is perl code. intelligent Text::MicroTemplate automatically escapes variables when and only when necessary. extensible Text::MicroTemplate does not provide features like template cache or including other files by itself. However, it is easy to add you own (that suites the most to your application), by wrapping the result of the module (which is a perl expression). The module only provides basic building blocks for a template engine. Refer to Text::MicroTemplate::File for higher-level interface. TEMPLATE SYNTAX
The template language is Perl5 itself! # output the result of expression with automatic escape <?= $expr ?> (tag style) ?= $expr (per-line) # execute perl code (tag style) <? foo() ?> ? foo() # comment (tag style) <?# comment ?> ?# comment # loops <ul> ? for my $item (@list) { <li><?= $item ?></li> ? } </ul> EXPORTABLE FUNCTIONS
build_mt($template) Returns a subref that renders given template. Parameters are equivalent to Text::MicroTemplate->new. # build template renderer at startup time and use it multiple times my $renderer = build_mt('hello, <?= $_[0] ?>!'); sub run { ... my $hello = $renderer->($query->param('user')); ... } render_mt($template, @args) Utility function that combines build_mt and call to the generated template builder. # render $hello = render_mt('hello, <?= $_[0] ?>!', 'John'); # print as HTML print $hello->as_string; # use the result in another template (no double-escapes) $enc = render_mt('<h1><?= $_[0] ?></h1>', $hello); Intertally, the function is equivalent to: build_mt($template)->(@_); encoded_string($str) wraps given string to an object that will not be escaped by the template engine OO-STYLE INTERFACE Text::MicroTemplate provides OO-style interface to handle more complex cases. new($template) new(%args) new(\%args) Constructs template renderer. In the second or third form, parameters below are recognized. template template string (mandatory) escape_func escape function (defaults to Text::MicroTemplate::escape_html), no escape when set to undef package_name package under where the renderer is compiled (defaults to caller package) code() returns perl code that renders the template when evaluated filter(sub filter_func { ... })->(sub { template lines }) filters given template lines ? $_mt->filter(sub { s/Hello/Good bye/g })->(sub { Hello, John! ? }) DEBUG
The "MICRO_TEMPLATE_DEBUG" environment variable helps debugging. The value 1 extends debugging messages, 2 reports compiled Perl code with "warn()", 3 is like 2 but uses "die()". SEE ALSO
Text::MicroTemplate::File Text::MicroTemplate::Extended AUTHOR
Kazuho Oku <kazuhooku gmail.com> Tokuhiro Matsuno <tokuhirom AAJKLFJEF GMAIL COM> The module is based on Mojo::Template by Sebastian Riedel. LICENSE
This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2010-09-06 Text::MicroTemplate(3pm)
All times are GMT -4. The time now is 02:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy