How Can We Help?
Below is a guide to the template commands and examples of how they can be used.
We know templates can appear complex, so if you have any questions or need any help, just email us at info@.com
Need help? We can create your custom templates for you. Just tell us what you need it to do, and we can code it. Basic advice is free; for more complex work, there may be a fee. Contact us for details.
List of commands:
- ignore_case_on();
- ignore_case_off();
- find_and_replace_regexp_text(‘Enter regular expression to find in HTML file’, ‘Enter regular expression to match and replace in text strings that were found’, ‘Regular expression or text used to replace any regexp matches’);
- replace_text(‘Text to replace in HTML file’, ‘New text’);
- replace_inner_text(‘Text to replace only inside HTML tags(inner text)’, ‘New text’);
- replace_regexp_text(‘Enter regular expression to match in HTML file’, ‘Text used to replace any regexp matches’);
- replace_tag_attribute(‘HTML tag to replace’, ‘HTML Attribute’, ‘New HTML Attribute’);
- replace_tag_attribute_no_quotes(‘HTML tag to replace’, ‘HTML Attribute’, ‘New HTML Attribute’);
- replace_tag_attribute_value(‘HTML tag to replace’, ‘HTML Attribute value to replace’, ‘New value’);
- replace_tag_attribute_value_no_quotes(‘HTML tag to replace’, ‘HTML Attribute value to replace’, ‘New value’);
- replace_inner_text_for_tag(‘HTML tag in which inner text will be replaced’, ‘Text to replace’, ‘New text’);
- delete_tag(‘HTML tag to delete in whole file’);
- delete_tag_with_content(‘HTML tag to delete in whole file with its inner html content’);
- delete_text(‘Text to delete in HTML file’);
- delete_attribute(‘Attribute to delete in HTML file for every tag’);
- delete_all_empty_tags();
- delete_empty_tag(‘HTML empty tag to delete in whole file, may contain spaces’);
- delete_inner_text(‘Text to delete only inside HTML tags[inner text]’);
- delete_regexp_text(‘Enter regular expression to delete in html file’);
- delete_inner_text_for_tag(‘HTML tag in which inner text will be replaced’, ‘Text to delete’);
- delete_tag_attribute(‘HTML tag in which attribute will be deleted’, ‘Attribute name’);
- delete_all_tag_attributes(‘HTML tag in which all attributes will be deleted’);
- add_tag_attribute(‘HTML tag to which attribute will be added’, ’New attribute with value’);
- add_html_after_opening_tag(‘HTML opening tag after which HTML will be added’, ‘Text/HTML string’);
- add_html_after_closing_tag(‘HTML closing tag after which HTML will be added’, ‘Text/HTML string’);
- add_html_before_opening_tag(‘HTML opening tag before which HTML will be added’, ‘Text/HTML string’);
- add_html_before_closing_tag(‘HTML closing tag before which HTML will be added’, ‘Text/HTML string’);
Turns on case ignoring when matching (searching for) a text to replace.
Turns off case ignoring when matching (searching for) a text to replace.
find_and_replace_regexp_text(‘Enter regular expression to find in HTML file’, ’Enter regular expression to match and replace in text strings that were found by previous expression’, ‘Regular expression or text used to replace any regexp matches from second expression’);
This powerful command can be used to do some regular expression find/replace/remove HTML processing for a given text that will be found by the first parameter of that command.
For example, the following command will search input HTML for a body tag, and it would process its manually entered emails (as text), and it would convert them to HTML versions of them.
find_and_replace_regexp_text(‘<body.*?</body>’,'([\w-]+)@([\w-]+\.)+\w+’,'<a href=”mailto:$0″>$0</a>’);
Input HTML:
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<title>EMAIL@TEST.COM</title>
</head>
<body>
<p>
EMAIL@TEST.COM
</p>
</body>
</html>
Output HTML:
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<title>EMAIL@TEST.COM</title>
</head>
<body>
<p>
<a href=”mailto:EMAIL@TEST.COM”>EMAIL@TEST.COM</a>
</p>
</body>
</html>
That command only processed the body (blue part) of the input HTML, and it changed its EMAIL@TEST.COM to the HTML version. If that command were executed for the whole input HTML, it would also change the email that is entered in <title>EMAIL@TEST.COM</title>, which would cause HTML syntax issues.
Example 2:
find_and_replace_regexp_text(‘<p[^<>]*?>.*?</p>’,'([\w-]+)@([\w-]+\.)+\w+’,'<a href=”mailto:$0″>$0</a>’);
Input HTML:
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<title>EMAIL@TEST.COM</title>
</head>
<body>
<p>
EMAIL@TEST.COM
</p>
<span>
EMAIL_SPAN@TEST.COM
</span>
<p>
EMAIL2@TEST2.COM
</p>
</body>
</html>
Output HTML:
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<title>EMAIL@TEST.COM</title>
</head>
<body>
<p>
<a href=”mailto:EMAIL@TEST.COM”>EMAIL@TEST.COM</a>
</p>
<span>
EMAIL_SPAN@TEST.COM
</span>
<p>
<a href=”mailto:EMAIL2@TEST2.COM”>EMAIL2@TEST2.COM</a>
</p>
</body>
</html>
That command was looking for any <p>…</p> tag occurrence in the input HTML and it changed its EMAIL@TEST.COM to the HTML version. If that command were executed for the whole input HTML, it would also change the email that is entered in <title>EMAIL@TEST.COM</title>, which would cause HTML syntax issues.
Please note that it did not process the <span> tag email.
replace_text(‘Text to replace in HTML file’, ’New text’);
A simple command to find and replace any text in an HTML file.
Example – finds all ‘foo1’ strings in the HTML file and replaces them with ‘foo2’:
Command:
replace_text(‘foo1′,’foo2’);
Input HTML:
<p>foo1 example</p>
<p>foo1foo1foo1</p>
<foo1>foo1</foo1>
Output:
<p>foo2 example</p>
<p>foo2foo2foo2</p>
<foo2>foo2</foo2>
replace_inner_text(‘Text to replace only inside HTML tags(inner text)’, ’New text’);
A simple command to find and replace in the inner text of an HTML file.
Example – finds all ‘foo1’ strings in inner text in html file and replaces it with ‘foo2’:
Command:
replace_inner_text(‘foo1′,’foo2’);
Input HTML:
<p>foo1 example</p>
<p>foo1foo1foo1</p>
<foo1>foo1</foo1>
Output:
<p>foo2 example</p>
<p>foo2foo2foo2</p>
<foo1>foo2</foo1>
replace_regexp_text(‘Enter regular expression to match in HTML file’, ‘Text used to replace any regexp matches’);
Command to find and replace text in an HTML file. The first parameter can contain regular expressions, and the second one can contain backreferences if there are any in the first parameter. For regexp backreferences, please look in the regular expressions tutorial.
Example 1– finds all <p>…</p> tags in html file and replaces it with ‘foo’ string:
Command:
replace_regexp_text(‘<p>.*?</p>’,’foo’);
Input HTML:
<p>foo1 example</p>
<p>foo1foo1foo1</p>
<foo1>foo1</foo1>
Output:
foo
foo
<foo1>foo1</foo1>
Example 2– finds all <p>…</p> tags in html file and leaves only inner text of <p> tag:
Command:
replace_regexp_text(‘<p>(.*?)</p>’,’$1′);
Input HTML:
<p>foo1 example</p>
<p>foo1<p>foo2</p><b>bold</b></p>
<foo1>foo1</foo1>
Output:
foo1 example
foo1<p>foo2<b>bold</b></p> !- this html line is broken because <p></p> tag was embedded in other <p></p> tag and example 2 regexp is mathing <p> and first occurrence of </p> closing tag
<foo1>foo1</foo1>
Example 3– deletes all <p>…</p> tags in html file:
Command:
replace_regexp_text(‘<p[^>/]*>.+?</p>’,”);
Input HTML:
<p>foo1 example</p>
<p>foo1<p>foo2</p><b>bold</b></p>
<foo1>foo1</foo1>
Output:
!- first line was removed correctly, but the line below was not all removed because <p> tags were embedded
<b>bold</b></p>
<foo1>foo1</foo1>
replace_tag_attribute(‘HTML tag to replace’, ‘HTML Attribute’, ‘New HTML Attribute’);
Command replaces the defined tag attribute with a new one in the HTML file.
Example – finds all <p> tags with attribute ‘id=”…”’ in an HTML file and replaces it with other_attribute=”ABC”:
Command:
replace_tag_attribute(‘p’,’id’,’other_attribute=”ABC”‘);
Input HTML:
<p id=”123″ bgcolor=”#ff00ff”>foo1 example</p>
<p bgcolor=”#ff00ff” id=”XYZ” >foo1 example</p>
<p>foo1 id=100</p>
Output:
<p other_attribute=”ABC” bgcolor=”#ff00ff”>foo1 example</p>
<p bgcolor=”#ff00ff” other_attribute=”ABC” >foo1 example</p>
<p>foo1 id=100</p>
replace_tag_attribute_no_quotes(‘HTML tag to replace’, ‘HTML Attribute’, ’New HTML Attribute’);
Command replaces the defined tag attribute with a new one in the HTML file. No quotes means that the attribute value has no “” (quotes).
Example – finds all <p> tags with attribute ‘id=…’ in in html file and replaces it with other_attribute=”ABC”:
Command:
replace_tag_attribute_no_quotes(‘p’,’id’,’other_attribute=”ABC”‘);
Input HTML:
<p id=123 bgcolor=”#ff00ff”>foo1 example</p>
<p bgcolor=”#ff00ff” id=”XYZ” >foo1 example</p>
<p>foo1 id=100</p>
Output:
<p other_attribute=”ABC” bgcolor=”#ff00ff”>foo1 example</p>
<p bgcolor=”#ff00ff” id=”XYZ”>foo1 example</p>
<p>foo1 other_attribute=”ABC”</p>
replace_tag_attribute_value(‘HTML tag to replace’, ‘HTML Attribute value to replace’, ’New value’);
Command replaces the defined tag attribute value with a new value in the HTML file.
Example – finds all <p> tags with attribute ‘id=”…”’ in an HTML file and replaces them with ABC:
Command:
replace_tag_attribute_value(‘p’,’id’,’ABC’);
Input HTML:
<p id=”123″ bgcolor=”#ff00ff”>foo1 example</p>
<p bgcolor=”#ff00ff” id=’XYZ’ >foo1 example</p>
<p>foo1 id=100</p>
Output:
<p id=”ABC” bgcolor=”#ff00ff”>foo1 example</p>
<p bgcolor=”#ff00ff” id=’ABC‘ >foo1 example</p>
<p>foo1 id=100</p>
replace_tag_attribute_value_no_quotes(‘HTML tag to replace’ , ‘HTML Attribute value to replace’, ‘New value’);
Command replaces the defined tag attribute value with a new value in the HTML file. No quotes means that the attribute value has no “” (quotes).
Example – finds all <p> tags with attribute ‘id=…’ in an HTML file and replaces them with ABC:
Command:
replace_tag_attribute_value_no_quotes(‘p’,’id’,’ABC’);
Input HTML:
<p id=123 bgcolor=”#ff00ff”>foo1 example</p>
<p bgcolor=”#ff00ff” id=”XYZ” >foo1 example</p>
<p>foo1 id=100</p>
Output:
<p id=ABC bgcolor=”#ff00ff”>foo1 example</p>
<p bgcolor=”#ff00ff” id=”XYZ” >foo1 example</p>
<p>foo1 id=ABC</p>
replace_inner_text_for_tag(‘HTML tag in which inner text will be replaced’, ‘Text to replace’, ‘New text’);
Command replaces the defined tag’s inner text, the first occurrence only of the parameter string to replace with the new string in the HTML file.
Example – finds all <p …> tags with ‘foo’ inside tag and replaces it with XXX:
Command:
replace_inner_text_for_tag(‘p’,’foo’,’XXX’);
Input HTML:
<p id=”123″>foo1 example</p>
<p bgcolor=”#ff00ff”>xxx foo examplefoo</p>
<p>foo2</p>
Output:
<p id=”123″>XXX1 example</p>
<p bgcolor=”#ff00ff”>xxx XXX examplefoo</p> !- blue underlined foo was not changed because this command matches first occurrence of foo only
<p>XXX2</p>
delete_tag(‘HTML tag to delete in whole file’);
Command deletes the defined tag HTML but leaves its contents in the HTML file.
Example – delete all <p …></p> tags:
Command:
delete_tag(‘p’);
Input HTML:
<p id=123>foo1 example</p>
<p bgcolor=”#ffeecc”>foo1<p>foo2</p><b>bold</b></p>
Output:
foo1 example
foo1foo2<b>bold</b>
delete_tag_with_content(‘HTML tag to delete in whole file’);
Command deletes the defined tag HTML with its inner contents from the HTML file.
Example – delete all <p …>…</p> tags:
Command:
delete_tag_with_content(‘p’);
Input HTML:
<p id=123>foo1 example</p>
<p bgcolor=”#ffeecc”>foo1<p>foo2</p><b>bold</b></p>
<b>foo</b>
Output:
!- first line was removed correctly, but the line below was not all removed because <p> tags were embedded
<b>bold</b></p>
<b>foo</b>
delete_text(‘Text to delete in HTML file’);
Command deletes defined text in the HTML file.
Example – delete all ‘foo‘ strings:
Command:
delete_text(‘foo’);
Input HTML:
<p id=foo>foo1 example</p>
<p bgcolor=”#ffeecc”>foo1<p>foo2</p><b>bold</b></p>
<foo1>foo1</foo1>
Output:
<p id=>1 example</p>
<p bgcolor=”#ffeecc”>1<p>2</p><b>bold</b></p>
<1>1</1>
delete_inner_text(‘Text to delete only inside HTML tags[inner text]’);
Command deletes the first occurrence of defined text in the inner text of an HTML tag in an HTML file.
Example – delete all ‘foo‘ strings in inner HTML:
Command:
delete_inner_text(‘foo’);
Input HTML:
<p id=foo>foo1 example</p>
<p bgcolor=”#ffeecc”>foo1<p>foofoofoo2</p><b>bold</b></p>
<foo1>foo1</foo1>
Output:
<p id=foo>1 example</p>
<p bgcolor=”#ffeecc”>1<p>foofoo2</p><b>bold</b></p> !- foofoo was not removed because it was the second and third occurrences
<foo1>1</foo1>
delete_regexp_text(‘Enter regular expression to delete in html file’);
Command to delete text in an HTML file. Parameters can contain a regular expression.
Example 1– deletes all <p>…</p> tags in html file:
Command:
delete_regexp_text(‘<p>.*?</p>’);
Input HTML:
<p id=foo>foo1 example</p>
<p bgcolor=”#ffeecc”>foo1<p>foofoofoo2</p><b>bold</b></p>
<p>foo1foo1foo1</p>
<foo1>foo1</foo1>
Output:
<p id=foo>foo1 example</p>
<p bgcolor=”#ffeecc”>foo1<b>bold</b></p>
<foo1>foo1</foo1>
delete_inner_text_for_tag(‘HTML tag in which inner text will be replaced’, ‘Text to delete’);
Command deletes the second parameter string in the defined tag’s inner text in the HTML file. It deletes the first occurrence of the second parameter only.
Example – finds all <p …> tags with ‘foo’ inside tag and deletes its fist occurrence:
Command:
delete_inner_text_for_tag(‘p’,’foo’);
Input HTML:
<p id=”123″>foo1 example</p>
<p bgcolor=”#ff00ff”>xxx foo examplefoo</p>
<p>foo2</p>
Output:
<p id=”123″>1 example</p>
<p bgcolor=”#ff00ff”>xxx examplefoo</p> !- blue underlined foo was not deleted because this command matches the first occurrence of foo only
<p>2</p>
Removes all empty tags (Empty tag: <tag>any white space inside</tag>).
For example: <p></p> or <p> </p> – will be removed from HTML.
delete_attribute(‘Attribute to delete in HTML file for every tag’);
Remove the defined HTML tag attribute from all HTML tags in the source HTML.
Example:
delete_attribute(‘style’);
Input HTML:
<p class=”test” style=”width:100px”>Test</p>
<span class=”test2” style=”height:100px”>Test2</span>
Output HTML:
<p class=”test”>Test</p>
<span class=”test2”>Test2</span>
delete_empty_tag(‘HTML tag to delete in whole file’);
Removes defined tag that is empty (Empty tag: <tag>any white space inside</tag>), for example, a command to remove all empty ‘p’ tags will be like this:
delete_empty_tag(‘p’);
Will result in all empty tags being removed from the HTML file
Input HTML:
<p> </p>
<p>TEST</p>
Output:
<p>TEST</p>
delete_tag_with_content(‘HTML tag to delete in whole file’);
Removes the defined tag with its inner content (inner text or HTML).
Example:
delete_tag_with_content(‘body’);
Will remove the body tag with all internal (inner) content it has.
delete_tag_attribute(‘HTML tag in which attribute will be deleted’, ‘Attribute name’);
Command deletes the defined tag attribute in the HTML file.
Example – finds all <p> tags with attribute ‘id=”…”’ in an HTML file and deletes its first occurrence:
Command:
delete_tag_attribute(‘p’,’id’);
Input HTML:
<p id=”123″ bgcolor=”#ff00ff”>foo1 example</p>
<p id=”123″ bgcolor=”#ff00ff” id=”123″>foo1 example</p>
<p>foo1 id=”100″</p>
Output:
<p bgcolor=”#ff00ff”>foo1 example</p>
<p bgcolor=”#ff00ff” id=”123″>foo1 example</p> !- blue underlined text was not deleted because this command matches the first occurrence of foo only
<p>foo1 id=”100″</p>
delete_all_tag_attributes(‘HTML tag in which all attributes will be deleted’);
Command deletes all attributes in the HTML file for a given tag.
Example – delete all <p> tag attributes in the HTML file:
Command:
delete_all_tag_attributes(‘p’);
Input HTML:
<p id=”123″ bgcolor=”#ff00ff”>foo1 example</p>
<p id=”123″ bgcolor=”#ff00ff” id=”123″>foo1 example</p>
<p>foo1 id=”100″</p>
Output:
<p>foo1 example</p>
<p>foo1 example</p>
<p>foo1 id=”100″</p>
add_tag_attribute(‘HTML tag to which attribute will be added’, ‘New attribute with value’);
Command adds a defined attribute to a tag in an HTML file.
Example – add to all <p> tags attribute ‘id=”123”’ in html file:
Command:
add_tag_attribute(‘p’,’id=”123”’);
Input HTML:
<p id=123 >foo1 example</p>
<p bgcolor=”#ffeecc”>foo1<p>foo2</p><b>bold</b></p>
<b>foo</b>
Output:
<p id=123 id=”123″>foo1 example</p>
<p bgcolor=”#ffeecc” id=”123″>foo1<p>foo2</p><b>bold</b></p>
<b>foo</b>
add_html_after_opening_tag(‘HTML opening tag after which HTML will be added’, ‘Text/HTML string’);
Command adds text or HTML after the opening tag in the HTML file.
Example – adds after all <p> tags ‘<b>A Bold Text Example</b>‘ in html file:
Command:
add_html_after_opening_tag(‘p’,'<b>A Bold Text Example</b>’);
Input HTML:
<p id=123 >foo1 example</p>
<p bgcolor=”#ffeecc”>foo1<p>foo2</p><b>bold</b></p>
<b>foo</b>
Output:
<p id=123><b>A Bold Text Example</b>foo1 example</p>
<p bgcolor=”#ffeecc”><b>A Bold Text Example</b>foo1<p><b>A Bold Text Example</b>foo2</p><b>bold</b></p>
<b>foo</b>
add_html_after_closing_tag(‘HTML closing tag after which HTML will be added’, ‘Text/HTML string’);
Command adds text or HTML after the closing tag in the HTML file.
Example – add after all </p> tags ‘<b>A Bold Text Example</b>‘ in html file:
Command:
add_html_after_closing_tag(‘p’,'<b>A Bold Text Example</b>’);
Input HTML:
<p id=123 >foo1 example</p>
<p bgcolor=”#ffeecc”>foo1<p>foo2</p><b>bold</b></p>
<b>foo</b>
Output:
<p id=123>foo1 example</p><b>A Bold Text Example</b>
<p bgcolor=”#ffeecc”>foo1<p>foo2</p><b>A Bold Text Example</b><b>bold</b></p><b>A Bold Text Example</b>
<b>foo</b>
add_html_before_opening_tag(‘HTML opening tag before which HTML will be added’, ‘Text/HTML string’);
Command adds text or HTML before the opening tag in the HTML file.
Example – add before all <p> tags ‘<b>A Bold Text Example</b>‘ in html file:
Command:
add_html_before_opening_tag(‘p’,'<b>A Bold Text Example</b>’);
Input HTML:
<p id=123 >foo1 example</p>
<p bgcolor=”#ffeecc”>foo1<p>foo2</p><b>bold</b></p>
<b>foo</b>
Output:
<b>A Bold Text Example</b><p id=123>foo1 example</p>
<b>A Bold Text Example</b><p bgcolor=”#ffeecc”>foo1<b>A Bold Text Example</b><p>foo2</p><b>bold</b></p>
<b>foo</b>
add_html_before_closing_tag(‘HTML closing tag before which HTML will be added’, ‘Text/HTML string’);
Command adds text or HTML before the closing tag in the HTML file.
Example – add before all </p> tags ‘<b>A Bold Text Example</b>‘ in html file:
Command:
add_html_before_closing_tag(‘p’,'<b>A Bold Text Example</b>’);
Input HTML:
<p id=123 >foo1 example</p>
<p bgcolor=”#ffeecc”>foo1<p>foo2</p><b>bold</b></p>
<b>foo</b>
Output:
<p id=123>foo1 example<b>A Bold Text Example</b></p>
<p bgcolor=”#ffeecc”>foo1<p>foo2<b>A Bold Text Example</b></p><b>bold</b><b>A Bold Text Example</b></p>
<b>foo</b>