Review often used templates

Jun 11, 2015


  • Recommended to examine the basic principles of formatting and the description of template processing system Template Toolkit. All examples can be tested independently in Template tester tool. In all examples at first used template is specified and through a separator ------ turned-out result is specified

    Saving simple results(top)

    Output of amount of results on request in parsers of search engines (for example SE::Google SE::Google)(top)

    Code:
    $query: $totalcount\n
    ------
    test: 765000000
    
    

    Output of quantity of the backlinks, referring pages and domains in parser Rank::Ahrefs Rank::Ahrefs(top)

    Code:
    $query - $total ($pages pages, $domains domains)\n
    ------
    a-parser.com - 6102 (1120 pages, 5 domains)
    
    

    Output domain PageRank in parser SE::Google::pR SE::Google::pR(top)

    Code:
    $query.orig: $pr\n
    ------
    a-parser.com: 0
    
    

    Output of rate request and date of up-dating statistics in parser SE::Yandex::WordStat SE::Yandex::WordStat(top)

    Code:
    $query - $totalcount, updated: $updatedate\n
    ------
    the test - 10837937, updated: 12.03.2014
    
    

    Saving all array cells(top)

    Output of list links from output in parser SE::Google SE::Google(top)

    Code:
    $serp.format (' $link\n')
    ------
    http://www.speedtest.net/
    http://www.speakeasy.net/speedtest/
    http://en.wikipedia.org/wiki/Test_cricket
    http://test-ipv6.com/
    http://www.humanmetrics.com/cgi-win/jtypes2.asp
    http://www.test.com/
    http://html5test.com/
    http://acid3.acidtests.org/
    http://www.bbc.co.uk/science/humanbody/mind/surveys/smiles/
    http://www.politicalcompass.org/test
    
    

    Output of all array cells(top)

    If to call the .format method without template, it will output names of all elements and array cells:
    Code:
    $serp.format ()
    ------
    anchor link snippet
    Speedtest.net by Ookla - The Global Broadband Speed <b>Test</b> http://www.speedtest.net/ <b>Test</b> your Internet connection bandwidth to locations around the world with this <br>interactive broadband speed <b>test</b> from Ookla.
    Speakeasy Speed <b>Test</b> http://www.speakeasy.net/speedtest/ Speakeasy Speed <b>Test</b> - Broadband Speed <b>Test</b>. Go to MegaPath Speed <b>Test</b> ... <br>02:38:36 PM Your IP: The Speakeasy Speed <b>Test</b> requires Flash v7 or higher.
    <b>Test</b> cricket - Wikipedia, the free encyclopedia http://en.wikipedia.org/wiki/Test_cricket <b>Test</b> cricket is the longest form of the sport of cricket. <b>Test</b> matches are played <br>between national representative teams with &quot;<b>Test</b> status&quot;, as determined by the&nbsp;...
    <b>Test</b> your IPv6. http://test-ipv6.com/ This will <b>test</b> your browser and connection for IPv6 readiness, as well as show <br>you your current IPV4 and IPv6 address. ... <b>Test</b> your IPv6 connectivity. JavaScript<br>&nbsp;...
    Personality <b>test</b> based on C. Jung and I. Briggs Myers type theory http://www.humanmetrics.com/cgi-win/jtypes2.asp Humanmetrics Jung Typology <b>Test</b>™ instrument uses methodology, <br>questionnaire, scoring and software that are proprietary to Humanmetrics, and <br>shall not be&nbsp;...
    Create <b>Tests</b> for Organizational Training and Certification Programs <b>...</b> http://www.test.com/ <b>Test</b>.com provides a complete software solution for creating online <b>tests</b> and <br>managing enterprise and specialist certification programs, in up to 22 languages.
    HTML5 <b>Test</b> http://html5test.com/ The HTML5 <b>test</b> score is an indication of how well your browser supports the <br>upcoming HTML5 standard and related specifications. Even though the&nbsp;...
    The Acid3 <b>Test</b> http://acid3.acidtests.org/ JS/? To pass the <b>test</b>, a browser must use its default settings, the animation has to <br>be smooth, the score has to end on 100/100, and the final page has to look&nbsp;...
    BBC - Science &amp; Nature - Human Body and Mind - Spot The Fake <b>...</b> http://www.bbc.co.uk/science/humanbody/mind/surveys/smiles/ This experiment is designed to <b>test</b> whether you can spot the difference between <br>a fake smile and a real one; It has 20 questions and should take you 10 minutes&nbsp;...
    The Political Compass - <b>Test</b> http://www.politicalcompass.org/test If you have come directly to this page from another site, please read our <br>homepage before continuing. Just a few propositions to start with, concerning - <br>no less&nbsp;...
    
    

    Output of an expiration date of registration domain and the list of all NS servers through a comma in a parser Net::Whois Net::Whois(top)

    Code:
    $query - expire: $expire_date, ns: $ns.format('$server, ')\n
    ------
    a-parser.com - expire: 25.02.2015, ns: erdomain.earth.orderbox-dns.com, erdomain.mars.orderbox-dns.com, erdomain.mercury.orderbox-dns.com, erdomain.venus.orderbox-dns.com,
    
    

    Output of keywords and their rate in parser SE::Yandex::WordStat SE::Yandex::WordStat(top)

    Code:
    Keywords:
    $keys.format('$key: $count\n')
    
    That looked with $query:
    $search.format('$key: $count\n')
    ------
    Keywords:
    тест: 10837937
    тест драйв: 1164338
    тесто +для теста: 879980
    тесты онлайн: 792560
    тест драйв видео: 550164
    рецепт теста: 484489
    тесты +с ответами: 449401
    тест 2014: 427602
    тесты бесплатно: 315144
    бесплатные тесты: 315096
    тесты +для девочек: 309355
    тесты +по темам: 293917
    игры тесты: 288989
    психологические тесты: 284248
    +из слоеного теста: 269226
    тесты +по русскому: 265836
    тесты 2013: 264651
    тест +на беременность: 260048
    скачать тест: 249363
    тесты +по русскому языку: 236294
    тест скорости: 229143
    тест 9: 222825
    тест 2: 221436
    тесты гиа: 201229
    тест интернета: 196851
    тест 7: 196561
    тест танки: 196539
    теста +для пиццы: 190383
    танкі тест: 189940
    тесты 9 класс: 184654
    тест скорости интернета: 183710
    4 4 тест: 181931
    тест 8: 180667
    тесты +по математике: 179761
    6 тест: 174955
    игры +для девочек тесты: 160112
    тесты егэ: 157127
    тест 3: 153268
    тест 1: 151041
    тесты 7 класс: 147506
    пройти тест: 145324
    проходить тесты: 145124
    онлайн тесты 2014: 141562
    +из дрожжевого теста: 139482
    краш тест: 138680
    тесты гиа 2014: 135846
    тест 10: 134944
    танки онлайн тест: 134393
    тесты 8 класс: 134024
    танкі онлайн тест: 133315
    
    
    That looked with test:
    mail: 18276944
    анекдоты: 1668731
    анекдоты +из россии: 21239
    анекдоты приколы: 9474
    приколы: 4888256
    test: 2089855
    test2: 10824
    наблюдение: 373761
    эксперимент +это: 8805
    проверка: 3101915
    структура текста: 6451
    текст: 12937150
    картинки +с животными: 40924
    картинки: 27668310
    картинки приколы: 137080
    уральский банк сбербанка россии: 5315
    берег: 1975805
    сибирский берег: 1098
    тестирование: 420945
    шизофрения лечение: 6038
    шизофрения: 120861
    ntcn: 9519
    мир вампиров: 2908
    вирт секс: 11504
    интеграция: 146388
    чат секса: 145299
    социометрия: 18289
    социометрия: 18289
    анкетирование: 64280
    анкетирование потребителей: 421
    контент анализ: 9462
    диаде: 3760
    методы исследования: 178530
    метод: 3792069
    психологическое тестирование: 6185
    тес: 44237
    spice girls: 9909
    kamchatka: 5564
    иван тургенев: 15338
    манная каша: 83627
    кузькин: 11170
    кузькина мать: 5270
    надёжность автомобилей: 8521
    mail: 18276944
    анекдоты: 1668731
    анекдоты +из россии: 21239
    анекдоты приколы: 9474
    приколы: 4888256
    test: 2089855
    test2: 10824
    

    Output initial request opposite to each link in parser SE::Google SE::Google(top)

    Code:
    $serp.format (' $query; $link\n')
    ------
    test; http://www.speedtest.net/
    test; http://www.speakeasy.net/speedtest/
    test; http://en.wikipedia.org/wiki/Test_cricket
    test; http://test-ipv6.com/
    test; http://www .humanmetrics.com/cgi-win/jtypes2.asp
    test; http://www.test.com/
    test; http://html5test.com/
    test; http://acid3.acidtests.org/
    test; http://www.bbc.co.uk/science/humanbody/mind/surveys/smiles/
    test; http://www.politicalcompass.org/test
    
    

    Use cycles(top)

    Output first 5 array cells(top)

    Code:
    [% FOREACH serp -%]
    $link $anchor
    [% LAST IF loop.count == 5 -%]
    [% END %]
    ------
    http://www.speedtest.net/ Speedtest.net by Ookla - The Global Broadband Speed <b>Test</b>
    http://www.speakeasy.net/speedtest/ Speakeasy Speed <b>Test</b>
    http://en.wikipedia.org/wiki/Test_cricket <b>Test</b> cricket - Wikipedia, the free encyclopedia
    http://test-ipv6.com/ <b>Test</b> your IPv6.
    http://www.humanmetrics.com/cgi-win/jtypes2.asp Personality <b>test</b> based on C. Jung and I. Briggs Myers type theory
    
    

    Output number of line item element in array(top)

    Code:
    [% FOREACH serp -%]
    $loop.index $loop.count $link
    [% END %]
    ------
    0 1 http://www.speedtest.net/
    1 2 http://www.speakeasy.net/speedtest/
    2 3 http://en.wikipedia.org/wiki/Test_cricket
    3 4 http://test-ipv6.com/
    4 5 http://www.humanmetrics.com/cgi-win/jtypes2.asp
    5 6 http://www.test.com/
    6 7 http://html5test.com/
    7 8 http://acid3.acidtests.org/
    8 9 http://www.bbc.co.uk/science/humanbody/mind/surveys/smiles/
    9 10 http://www.politicalcompass.org/test
    
    

    Output of even array cells(top)

    Code:
    [% FOREACH serp -%]
    [% NEXT IF loop.count % 2 -%]
    $link $anchor
    [% END %]
    ------
    http://www.speakeasy.net/speedtest/ Speakeasy Speed <b>Test</b>
    http://test-ipv6.com/ <b>Test</b> your IPv6.
    http://www.test.com/ Create <b>Tests</b> for Organizational Training and Certification Programs <b>...</b>
    http://acid3.acidtests.org/ The Acid3 <b>Test</b>
    http://www.politicalcompass.org/test The Political Compass - <b>Test</b>
    http://www.ets.org/test_link/about <b>Test</b> Link: About the <b>Test</b> Collection - ETS
    http://www.ozspeedtest.com/ Oz Broadband Speed <b>Test</b>: Speed <b>Test</b> - Home
    http://www.cambridgeenglish.org/test-your-english/ <b>Test</b> your English - Cambridge English
    http://www.keirsey.com/sorter/register.aspx by taking the Keirsey Temperament Sorter-II - Personality <b>Test</b> <b>...</b>
    http://www.kaptest.com/ Welcome to Kaplan <b>Test</b> Prep
    
    

    Search of keys and values of each array cell(top)

    Code:
    [% FOREACH el = serp -%]
    [% FOREACH el -%]
    $key: $value
    [% END -%]
    [% END %]
    ------
    anchor: Speedtest.net by Ookla - The Global Broadband Speed <b>Test</b>
    link: http://www.speedtest.net/
    snippet: <b>Test</b> your Internet connection bandwidth to locations around the world with this <br>interactive broadband speed <b>test</b> from Ookla.
    anchor: Speakeasy Speed <b>Test</b>
    link: http://www.speakeasy.net/speedtest/
    snippet: Speakeasy Speed <b>Test</b> - Broadband Speed <b>Test</b>. Go to MegaPath Speed <b>Test</b> ... <br>02:38:36 PM Your IP: The Speakeasy Speed <b>Test</b> requires Flash v7 or higher.
    anchor: <b>Test</b> cricket - Wikipedia, the free encyclopedia
    link: http://en.wikipedia.org/wiki/Test_cricket
    snippet: <b>Test</b> cricket is the longest form of the sport of cricket. <b>Test</b> matches are played <br>between national representative teams with &quot;<b>Test</b> status&quot;, as determined by the&nbsp;...
    
    

    Conditional expressions(top)

    Backlighting of value depending on amount of results in SE::Google SE::Google(top)

    Code:
    $query: <font color="[% IF totalcount > 1000 %]green[% ELSE %]red[% END %]">$totalcount</font>
    ------
    test: <font color="green">765000000</font>
    
    

    Text representation result of check site in SE::Google::SafeBrowsing SE::Google::SafeBrowsing(top)

    Code:
    $query: [% IF exists %]Yes[% ELSE %]No[% END %]
    $query: [% exists ? 'Yes' : 'No' %]
    ------
    unblss.com: Yes
    unblss.com: Yes
    
    

    Saving links only of a certain length(top)

    Code:
    [% FOREACH serp -%]
    [% NEXT IF link.length > 20 -%]
    $link
    [% END %]
    ------
    http://www.test.com/
    http://www.test.nl/
    http://test.org.uk/
    http://www.astm.org/
    
    

    Plug-ins and filters(top)

    Output of all variables and their values in parser Net::Whois Net::Whois(top)

    Code:
    [% USE dumper; dumper.dump(root) %]
    ------
    $VAR1 = {
              'ns' => [
                        {
                          'server' => 'erdomain.earth.orderbox-dns.com'
                        },
                        {
                          'server' => 'erdomain.mars.orderbox-dns.com'
                        },
                        {
                          'server' => 'erdomain.mercury.orderbox-dns.com'
                        },
                        {
                          'server' => 'erdomain.venus.orderbox-dns.com'
                        }
                      ],
              'info' => {
                          'success' => 1,
                          'retries' => 1,
                          'stats' => 'proxiesUsed: 1
    queries: 1
    requests: 1
    retries: 1
    success: 1'
                        },
              'expire_date' => '25.02.2015',
              'registered' => 1,
              'creation_date' => '25.02.2012',
              'query' => {
                           'first' => 'http://a-parser.com/',
                           'lvl' => 0,
                           'query' => 'a-parser.com',
                           'queryUid' => 0,
                           'orig' => 'http://a-parser.com/'
                         },
              'whoisserver' => 'whois.crsnic.net',
              'root' => $VAR1,
              'statuses' => [
                              {
                                'status' => 'clientTransferProhibited'
                              }
                            ]
            };
    
    

    Removing HTML code in snippets in parser SE::Google SE::Google(top)

    Code:
    [% FOREACH serp -%]
    [% snippet
    remove('<[^>]*>') %]
    [% END %]
    ------
    Test your Internet connection bandwidth to locations around the world with this interactive broadband speed test from Ookla.
    Speakeasy Speed Test - Broadband Speed Test. Go to MegaPath Speed Test ... 02:38:36 PM Your IP: The Speakeasy Speed Test requires Flash v7 or higher.
    Test cricket is the longest form of the sport of cricket. Test matches are played between national representative teams with &quot;Test status&quot;, as determined by the&nbsp;...
    This will test your browser and connection for IPv6 readiness, as well as show you your current IPV4 and IPv6 address. ... Test your IPv6 connectivity. JavaScript&nbsp;...
    Humanmetrics Jung Typology Test™ instrument uses methodology, questionnaire, scoring and software that are proprietary to Humanmetrics, and shall not be&nbsp;...
    Test.com provides a complete software solution for creating online tests and managing enterprise and specialist certification programs, in up to 22 languages.
    The HTML5 test score is an indication of how well your browser supports the upcoming HTML5 standard and related specifications. Even though the&nbsp;...
    JS/? To pass the test, a browser must use its default settings, the animation has to be smooth, the score has to end on 100/100, and the final page has to look&nbsp;...
    This experiment is designed to test whether you can spot the difference between a fake smile and a real one; It has 20 questions and should take you 10 minutes&nbsp;...
    If you have come directly to this page from another site, please read our homepage before continuing. Just a few propositions to start with, concerning - no less&nbsp;...
    
    

    Output time when request was parsed(top)

    Code:
    [% USE date -%]
    Request $query parsed at [% date.format(format = '%H:%M:%S') %]
    ------
    Request test parsed at 08:32:17
    
    
zbest, Metroid and Support like this.