Code Monkey home page Code Monkey logo

eps's Introduction

  • 👋 Hi, I’m @straightdave
  • 👀 I’m interested in ...
  • 🌱 I’m currently learning ...
  • 💞️ I’m looking to collaborate on ...
  • 📫 How to reach me ...

eps's People

Contributors

dbroeglin avatar icodesometime avatar kimuraw avatar qbikez avatar straightdave avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

eps's Issues

Add new template function for IfNullOrEmpty

The Each function is very helpful, but I noticed that a regularly want to use a default value if the actual one isn't set.

This is mostly in loop where some parameter/options are global, but could be overwritten. Currently I use something like <%= if ( $_.value ) { $_.value } else { $global.value ] %>

Although this works perfectly it's quite some effort. A shorter version would be great.

BTW: Thanks for building and maintaining this templating engine, I really appreciate that :)

Error output of large templates should be more readable

Hi,

I though it would be possible to use this module against a HTML template but it seems not to be working in following situation:

Running following call

Invoke-EpsTemplate -Path $TemplateFilePath -Binding @{ ReportObj = $this } | Out-File $HtmlReportPath

returns following error:

> System.Management.Automation.MethodInvocationException                                                   Exception calling "Create" with "1" argument(s): "At line:2 char:7                                              + [void]$(                                              +       ~~                                              $(subexpression) is missing the closing ')'.                                                                                            At line:55 char:85                                              + ... eDescription())");;$sb.Append("</dd>                                              +                    ~~                                              The string is missing the terminator: ".                                                                                            At line:55 char:85                                              + ... eDescription())");;$sb.Append("</dd>                                              +                    ~~                                              Unexpected token '")' in expression or statement.                                                                                            At line:55 char:88                                              + ... scription())");;$sb.Append("</dd>                                              +                    ~                                              Missing closing ')' in subexpression.                                                                                           At line:55 char:101                                              + ... );;$sb.Append("</dd>                                              +                    ~                                              Missing ')' in method call.                                                                                            At line:55 char:101                                              + ... );;$sb.Append("</dd>                                              +                    ~                                              The '<' operator is reserved for future use.                                                                                            At line:57 char:96                                              + ... ValidityDate())");;$sb.Append("</dd>                                              +                    ~~                                              The string is missing the terminator: ".                                                                                            At line:57 char:96                                              + ... ValidityDate())");;$sb.Append("</dd>                                              +                    ~~                                              Unexpected token '")' in expression or statement.                                                                                            At line:57 char:99                                              + ... idityDate())");;$sb.Append("</dd>                                              +                    ~                                              Missing closing ')' in subexpression.         

Here is the HTML code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="robots" content="noindex">
        <title>Database Backup Policy - <%=($ApplicationName)%> - <%=($ApplicationEnvironment)%> (Generated on <%=($GenerationDateTimeStr)%>)</title>
        <link rel="stylesheet" href="css/stylesheet.css" type="text/css" media="all"/>
        <link rel="stylesheet" href="css/jquery-ui.css" type="text/css" media="all" />
        <script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
        <script src="js/jquery-ui.js" type="text/javascript" charset="utf-8"></script>
        <script src="js/custom.js" type="text/javascript" charset="utf-8"/>
    </head>
    <body>
        <h1>Database Backup Policy</h1>
        <div id="loader">
            <div id="circularG">
                <div id="circularG_1" class="circularG"></div>
                <div id="circularG_2" class="circularG"></div>
                <div id="circularG_3" class="circularG"></div>
                <div id="circularG_4" class="circularG"></div>
                <div id="circularG_5" class="circularG"></div>
                <div id="circularG_6" class="circularG"></div>
                <div id="circularG_7" class="circularG"></div>
                <div id="circularG_8" class="circularG"></div>
            </div>
            <span class="loader_text"> Please wait</span>
        </div>
        </div>
        <div id="content">
            <!--
            <div class="error">First Error</div>
            <div class="info">Info Message</div>
            <div class="info">Number of known shells in database is: 603</div>
            -->
            <dl>
                <dt>Report generation details</dt>
                <dd>
                    <dl>
                        <dt>Generated on:</dt>
                        <dd><%=($ReportObj.GetReportGenerationDateTime())%></dd>
                        <dt>Application Name:</dt>
                        <dd class="red"><%=($ReportObj.ApplicationName)%></dd>
                        <dt >Environment:</dt>
                        <dd class="red"><%=($ReportObj.ApplicationEnvironment)%></dd>
                        <dt>RDBMS:</dt>
                        <dd><%=($ReportObj.ApplicationRDBMS)%></dd>
                        <dt>InstanceNames:</dt>
                        <dd><%=($ReportObj.GetApplicationInstanceNames())%></dd>
                        <dt>Comments on Application:</dt>
                        <dd><%=($ReportObj.GetApplicationComments())%></dd>
                        <dt>Data sample:</dt>
                        <dd><%=($ReportObj.GetDataSampleDescription()%></dd>
                        <dt>Report valid until:</dt>
                        <dd class="red"><%=($ReportObj.GetReportValidityDate()%></dd>
                    </dl>
                </dd>
            </dl>
            
            <dl>
                <dt>Backup times in a day<span class="plus">-</span></dt>
                <dd>
                    <dl>
                            <table class="DataTable">
                                <th class="blank"></th>
                                <th>StartTime</th>
                                <th>Duration (Avg)</th>
                                <th>Duration (Max)</th>
                                <th>Size (Avg)</th>
                                <th>Size (Max)</th>
                                <th>Accuracy (%)</th>
                                <tr>
                                    <td>FULL</td>
                                    <td>23:00</td>
                                    <td>03:20</td>
                                    <td>03:20</td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td>LOG</td>
                                    <td>13:00</td>
                                    <td>01:20</td>
                                    <td>01:20</td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                </tr>
                            </table>
                    </dl>

            </dl>
            <dl>
                <dt>Backup timeline (Avg Duration)<span class="plus">-</span></dt>
                <dd>
                    <dl>
                        

                            <table class="DataTable">
                                <th class="blank"></th>
                                <th>00</th>
                                <th>01</th>
                                <th>02</th>
                                <th>03</th>
                                <th>04</th>
                                <th>05</th>
                                <th>06</th>
                                <th>07</th>
                                <th>08</th>
                                <th>09</th>
                                <th>10</th>
                                <th>11</th>
                                <th>12</th>
                                <th>13</th>
                                <th>14</th>
                                <th>15</th>
                                <th>16</th>
                                <th>17</th>
                                <th>18</th>
                                <th>19</th>
                                <th>20</th>
                                <th>21</th>
                                <th>22</th>
                                <th>23</th>
                                <tr>
                                    <td>Day 1</td>
                                    <td>F</td>
                                    <td>F</td>
                                    <td>F</td>
                                    <td></td>
                                    <td></td>
                                    <td>L</td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td>L</td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td>F</td>
                                </tr>
                                <tr>
                                    <td>Day 2</td>
                                    <td>F</td>
                                    <td>F</td>
                                    <td>F</td>
                                    <td></td>
                                    <td></td>
                                    <td>L</td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td>L</td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td>F</td>
                                </tr>
                                <tr>
                                </tr>
                            </table>
                    </dl>

            </dl>
            <dl>
                <dt>Average duration over time<span class="plus">-</span> </dt>
                <dd>
                    <dl>
                        <p>TODO: generate image and add it here</p>
                    </dl>
                </dd>
            </dl>
            <dl>
                <dt>Average Backup Size over time<span class="plus">-</span></dt>
                <dd>
                    <dl>
                        <p>TODO: generate image and add it here</p>
                    </dl>
                </dd>
            </dl>
            <div class="clearer"></div>
            <!--<div class="error"><strong>Status</strong>: 1 suspicious files found and <strong>3</strong> shells found</div>-->
        </div>
    </body>
</html>


Error calling custom functions from the template syntax?

Using the sample code below, I get the following error:

Invoke-EpsTemplate : Exception calling "InvokeWithContext" with "2" argument(s): "The term 'SentenceCase' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again."

Note I'm not using the -Safe switch. Wondering if this is a bug, or a feature? Thanks in advance.

Import-Module EPS

function SentenceCase
{
    [CmdletBinding()]
    Param(
        [Parameter(ValueFromPipeline)]
        [String]$word
    )

    return $word.Substring(0, 1).ToUpper() + $word.Substring(1).ToLower()
}

$template = "<%= 'hello' | SentenceCase %>"

$results = Invoke-EpsTemplate -Template $template

Write-Host $results

Multiline <%= ... %> does not work

Should have kept quiet, I jinxed it ;-)

A colleague of mine found a bug with the <%= ... %> syntax. It looks like multiple lines in it cause the whole expression to be ignored. I added the following test to the unit tests to show the issue:

               It 'expands "<%= $A.B`n %>" to "XXX"' {
                       $binding | Expand-Template -Template "<%= `$A.B`n %>" | Should Be "XXX`n"
               }

It should return "XXX\n" but actually returns just "\n".

ThrowForEmptyInsert not compatible with many features

A simple scriptblock like this works in EPS:

<%= if ($true) { "true" } else { "false" }  %>

However if the templating is invoked with ThrowForEmptyInsert, it throws the following error:

New-EpsTemplateScript : Exception calling "Create" with "1" argument(s): "At line:4 char:74
+ ... : `"");$sb.Append("$(if ($true) { "true" } else { "false" } | Get-OrE ...
+                                                                 ~
An empty pipe element is not allowed."

If the script block is wrapped like follows:

<%= (if ($true) { "true" } else { "false" })  %>

the error no longer occurs but no output is created for the entire template (null).

I haven't had a chance to dig into this any further.

Variables whose name is other than `name` or `name_value` don't work in script

Say I have this test.esp:

Without underscore: <%= $name %>
With underscore: <%= $name_value %>

If I run it directly on shell, it works fine:

$name = 'ABC'
$name_value = 'ABC'

Invoke-EpsTemplate -Path .\test.esp
Without underscore: ABC
With underscore: ABC

But if I put them in a build.ps1 script:

$name = 'ABC'
$name_value = 'ABC'
Invoke-EpsTemplate -Path .\test.esp

Then it doesn't work:

.build.ps1
Without underscore: ABC
With underscore:

This is also true for any variable name I try, except name and name_value. Even name_values doesn't work. Why is that?

<% ... %> should not generate content

I stepped up my use of EPS quite a bit. Both for configuration generation and for my code generation module https://github.com/dbroeglin/Forge.Module

So far everything is working neatly except one point. Output in <% %> often confuses people. To use that correctly it is necessary to understand the template engine's inner workings. For most people that engenders confusion. I would suggest we, altogether, remove the ability to generate content within <% %>. There is not reduction in features as one can always use <%= %> to generate content. And it makes things easier to understand.

If you agree I can implement the change and submit a PR.

Unable to import modules.

Hello,

I'm having difficulty importing your module. If seems to hang when I run the the below from my ps1 script....

Import-Module "$(Join-Path $solutionPath 'ps-scripts\EPS')" -Force

The console displays...

VERBOSE: Loading module from path 'C:\dbgit\db-publish\ps-scripts\EPS\EPS.psd1'.
VERBOSE: Loading module from path 'C:\dbgit\db-publish\ps-scripts\EPS\EPS.psm1'.

I can't seem to run any code after the import module command, please advise.

Thanks

Is it possible to make Invoke-EpsTemplate fail if a binding is missing?

Hey there, wonderful job on this templating engine! 😄

Currently, if a binding is missing, it seems to proceed silently.

e.g.

PS C:\Users\fots> type .\test.eps
Hello there <%= $Name %>, how are you today?
PS C:\Users\fots> Invoke-EpsTemplate -Path .\test.eps
Hello there , how are you today?

PS C:\Users\fots> $ErrorActionPreference = 'Stop'
PS C:\Users\fots> Invoke-EpsTemplate -Path .\test.eps
Hello there , how are you today?

PS C:\Users\fots> Invoke-EpsTemplate -Path .\test.eps -ErrorAction Stop
Hello there , how are you today?

Is there any way to make this more strict and fail if a variable is not set?

Thanks heaps
Fotis

feature: DSC Module

Would be lovely to see a Desired State Configuration Composite Resource wrapper around eps.

Would allow one to be able to declaratively state/instantiate files from eps template. Something akin to the following DSC pseudo-code could be used for config management of a node's service configuration, for instance:

$epsBindingParams = @{
...
}

EpsTemplate MyConfigFile {
    Name = "someConfig.ini"
    Path = "someConfig.ini.eps"
    Binding = @epsBindingParams
}

And, given the same input -bindings and -path, the final eps output ought to always be the same (ie pure function), so comparing the hash of the eps output against any existing target file-on-disk should suffice as the Get and Test scenarios of a DSC Resource's required {Get, Test, Set} methods.


Also, thanks @straightdave for your efforts re: EPS PowerShell module in general- much appreciated!

Feature request : "For" tag in template

Hello !
Very interesting module.
For my need, i would like to use "For" tags in templates.

Equivalent in Twig is :

`

Members

    {% for user in users %}
  • {{ user.username|e }}
  • {% endfor %}
`

Do you think is possible to implement that ?

Kind regards.

Double quotes are not properly escaped

Example:

Invoke-EpsTemplate -Template '<%= $test | Get-OrElse -Default "" %>'

Output

New-EpsTemplateScript : Exception calling "Create" with "1" argument(s): "At line:3 char:44
+ ;$sb.Append("$($test | Get-OrElse -Default "")");
+                                            ~~
The string is missing the terminator: ".
At line:3 char:47
+ ;$sb.Append("$($test | Get-OrElse -Default "")");
+                                               ~
Missing closing ')' in subexpression."
At line:28 char:28
+     $templateScriptBlock = New-EpsTemplateScript -Template $Template
+                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-EpsTemplateScript], MethodInvocationException
    + FullyQualifiedErrorId : ParseException,New-EpsTemplateScript

Calling Invoke-EpsTemplate Inside for loop

I know this repo is old, I'm really hoping someone is watching this, so here goes.

I'm using eps to create tf files that are passed to modules. For one resource there are a list of nested resources, so this script calls two templates, one to create the main tf and one to create the vars.tf that is passed in. When I run the vars eps template with a group of objects, it returns as expected.

When i run in the context of the script, the eps doesn't iterate over the objects passed in. I'm curious if that's because I'm calling invoke from inside a for loop and that's somehow messing things up?

Here's some stripped down samples, cant' really share everything sorry:

Calling script

$Groups = $Resource | Group-Object -Property ServerName;
$ListPath = $TemplatePath.Replace('.eps', '-list.eps');

  foreach ($Group in $Groups) {
   
    $ModuleName = "$($ServerName)-$([System.Guid]::NewGuid().Guid)";
   
      Invoke-EpsTemplate -Path $TemplatePath -binding @{
        ModuleName = $ModuleName;
        Source     = $Source;
        ResourceId = $ResourceId;
      } -Safe
      Invoke-EpsTemplate -Path $ListPath -Binding @{
        ModuleName = $ModuleName;
        Resource   = $Group.Group;
      }
    }
  }

Initial eps

module "<%= $ModuleName %>" {
  source             = "<%= $Source %>"

  list            = "<%= "var.$($ModuleName)_list" %>"

}

looped eps

variable "<%= "$($ModuleName)_list" %>" {
  default = [
<% $Count = 0 -%>
<% $Resource |ForEach-Object { -%>
    {
      name                  = "<%= $_.Name %>"
<% $Count++ -%>
    }<% if (!($Count -eq $Resource.Count)) { %>,<% } %>
<% } -%>
  ]
}

The resulting output when run through the script is below

module "sample1-550fc654-4e82-4913-a8ec-d08a14c13ed2" {
  source             = "github"
  list            = "var.sample1-550fc654-4e82-4913-a8ec-d08a14c13ed2_list"
}
variable "sample1-550fc654-4e82-4913-a8ec-d08a14c13ed2_list" {
  default = [
    {
      name                  = "subname1"
    },
  ]
}
module "sample2-f217ea8d-35a5-4c01-96d2-40268b8512f4" {
  source             = "github"
  list            = "var.sample2-f217ea8d-35a5-4c01-96d2-40268b8512f4_list"
}
variable "sample2-f217ea8d-35a5-4c01-96d2-40268b8512f4_list" {
  default = [
    {
      name                  = "subnamea"
    },
  ]
}

The resource that is passed in is an array of psobjects that have n+1 unique ServerNames.

ServerName resourceName
---------- ------------
server1    sample1
server1    sample2
server1    sample3
server1    sample4
server1    sample5
server2    samplea
server2    sampleb
server2    samplec
server2    sampled

Unbalanced brackets in template casue exception

An unbalanced bracket in the template (not the powershell expression) causes an exception. For example, adding ( to the first example in the README:

$name = "Dave"
Invoke-EpsTemplate -Template 'Hello ( <%= $name %>!'

Results in the following:

New-EpsTemplateScript : Exception calling "Create" with "1" argument(s): "At line:2 char:7
+ [void]$(
+       ~~
$(subexpression) is missing the closing ')'.

Refactoring proposition for multiline tags and trimming

I tried to solve the issues I mentioned earlier and, err... got a bit carried away...

I refactored the code quite a bit, drawing inspiration from erubi:
https://github.com/jeremyevans/erubi/blob/master/lib/erubi.rb

What I tried to do is get to the point where the code conforms to that specification (for the ERB part, not the Puppet part):
https://docs.puppet.com/puppet/latest/reference/lang_template_erb.html

It means a few breaking changes like:

  1. No more output from a <% ... %> tag
  2. No more line breaks added at the end of the template
  3. Maybe some others I missed
  4. Refactored the cmdlet names (again, because I understand PS idioms a bit better than last time)

To be sure that it actually works I added quite a few tests:
https://github.com/dbroeglin/eps/blob/exp/refactoring/Tests/Invoke-EpsTemplate.Tests.ps1

The result can be found here:
https://github.com/dbroeglin/eps/blob/exp/refactoring/EPS/Invoke-EpsTemplate.ps1

It is not a pull request, just a branch in my repository. I would like to get your feedback before going any further.

Uploading EPS to the PowerShell Gallery

I'm using the last version of the code for some time now, it seems to work quite nicely. Also, I started using it in a module of my own: https://github.com/dbroeglin/Forge

I'm not copying it, I just do an Import-Module EPS, so it would be nice if someone wants to use it that they just can do an Install-Module EPS .

To facilitate the publication I added some information in the PSD1 file (see #6). You can just review and adapt it, create an account to access https://www.powershellgallery.com/packages/upload and do a Publish-Module.

I don't want to bother you more than necessary and if you do not have time I could do it for you. However, it would not be fair to your work as my account would be associated with the upload. And I think credit should be given where it is due! ;-)

[Feature Request] Support for partial templates

I just want to take a moment and say that when I went searching for templating in PowerShell, this was at the top of the search results. And after looking through the examples and ReadMe, it seems to be a really nice templating DSL. I'm working on porting a JavaScript library, which is making use of handlebars templates, and I'm considering (strongly) taking a dependency on this to achieve a similar effect! Thanks for making this!

I don't see that there is any support for "partial templates". It would be nice to be able to split up larger templates, especially those which may contain conditional or repetitive sections, into several smaller templates, and have a "master" template reference the partial templates.

(P.S. I know this repo hasn't been updated in a while, so I'm just opening this request so it has visibility. Depending on my time and my project requirements, this may be something I could look into adding—no promises—but, in case anyone else is so inclined, here's the request 😉 )

Error when trimming eol : <% ... -%>`n<% ... %>

The following template would work (generates a new line):

<% `$a = 5 %>`n<% if (`$a) { } %>

However if EOL trimming is added it does not work anymore:

<% `$a = 5 -%>`n<% if (`$a) { } %>

The reason is because the generated executable code looks like:

$a = 5  if ($a) { }

parser error

what's wrong with following template code? thxs!

Import-Module EPS
$xml = [xml]@'
<?xml version='1.0' encoding='UTF-8'?>
<elements>
  <element>
    <filename>contract-selection-dialog.component.ts</filename>
    <name>Title</name>
    <component>Contract Manager</component>
    <dialog>Contract Selection Dialog</dialog>
    <selector action="text" type="css">.cbContractSelectionDialog h1</selector>
  </element>
  <element>
    <filename>contract-selection-dialog.component.ts</filename>
    <name>Select Button</name>
    <component>Contract Manager</component>
    <dialog>Contract Selection Dialog</dialog>
    <selector action="click" type="css">.cbSelectContractButton</selector>
    <selector action="text" type="css">.cbSelectContractButton</selector>
    <selector action="afterClickAppear" type="css">mat-expansion-panel</selector>
    <selector action="afterClickDisappear" type="css">mat-dialog-container</selector>
  </element>
  <element>
    <filename>contract-selection-dialog.component.ts</filename>
    <name>Tab</name>
    <component>Contract Manager</component>
    <dialog>Contract Selection Dialog</dialog>
    <selector action="count" type="css">.cbContractSelectionDialog .mat-tab-label</selector>
    <selector action="click" type="css">.cbContractSelectionDialog .mat-tab-label:nth-child(n)</selector>
    <selector action="text" type="css">.cbContractSelectionDialog .mat-tab-label:nth-child(n) .mat-tab-label-content</selector>
  </element>
</elements>
'@

$elements = $xml.SelectNodes("//element")

#  <element>
#    <filename>aaa</filename>
#    <name>bbb</name>
#    <component>ccc</component>
#    <dialog>ddd</dialog>
#    <selector action="eee" type="fff">ggg</selector>
#  </element>

$result = Invoke-EpsTemplate -Template @'
<%= $elements | Each { -%>
#   <element>
#     <filename><%= $($_.filename) %></filename>
#     <name><%= $($_.name) %></name>
#     <component><%= $($_.component) %></component>
#     <dialog><%= $($_.dialog) %></dialog>
<%= $($_.selector) | Each { -%>
#     <selector action="<%= $($_.action) %>" type="<%= $($_.type) %>"><%= $($_.'#text') %></selector>
<% } -%>
#   </element>
<%= if( $($_.selector.action ) -eq "afterClickAppear") { -%>
<%= $($_.component) %> [- <%= $($_.dialog) %>] - <%= $($_.name) %> Check Not Visible
    SeleniumLibrary.Element Should Not Be Visible                                    <%= $($_.selector.type) %>:<%= $($_.selector.'#text') %>
<%= $($_.component) %> [- <%= $($_.dialog) %>] - <%= $($_.name) %> Wait Appear
    SeleniumLibrary.Wait Until Element is Visible                                    <%= $($_.selector.type) %>:<%= $($_.selector.'#text') %>
<% } -%>
<%= if( $($_.selector.action) -eq "afterClickDisappear") { -%>
<%= $($_.component) %> [- <%= $($_.dialog) %>] - <%= $($_.name) %> Check Visible
    SeleniumLibrary.Element Should Be Visible                                        <%= $($_.selector.type) %>:<%= $($_.selector.'#text') %>
<%= $($_.component) %> [- <%= $($_.dialog) %>] - <%= $($_.name) %> Wait Disappear
    SeleniumLibrary.Wait Until Element is NOT Visible                                <%= $($_.selector.type) %>:<%= $($_.selector.'#text') %>
<% } -%>
<%= if( $($_.selector.action) -eq "afterHoverAppear") { -%>
<%= $($_.component) %> [- <%= $($_.dialog) %>] - <%= $($_.name) %> Check Not Visible
    SeleniumLibrary.Element Should Not Be Visible                                    <%= $($_.selector.type) %>:<%= $($_.selector.'#text') %>
<%= $($_.component) %> [- <%= $($_.dialog) %>] - <%= $($_.name) %> Wait Appear
    SeleniumLibrary.Wait Until Element is Visible                                    <%= $($_.selector.type) %>:<%= $($_.selector.'#text') %>
<% } -%>
<%= if( $($_.selector.action) -eq "click") { -%>
<%= $($_.component) %> [- <%= $($_.dialog) %>] - <%= $($_.name) %> Click
    SeleniumLibrary.Click Element                                                    <%= $($_.selector.type) %>:<%= $($_.selector.'#text') %>
<%= $($_.component) %> [- <%= $($_.dialog) %>] - <%= $($_.name) %> Check Enabled
    Run Keyword And Continue On Failure    SeleniumLibrary.Element Should be Enabled     <%= $($_.selector.type) %>:<%= $($_.selector.'#text') %>
<%= $($_.component) %> [- <%= $($_.dialog) %>] - <%= $($_.name) %> Check Disabled
    Run Keyword And Continue On Failure    SeleniumLibrary.Element Should be Disabled    <%= $($_.selector.type) %>:<%= $($_.selector.'#text') %>
<% } -%>
<%= if( $_.selector.action -eq "exist" ) { -%>
<%= $($_.component) %> [- <%= $($_.dialog) %>] - <%= $($_.name) %> Check Exist
    [arguments]     ${text}	
    Run Keyword And Continue On Failure    SeleniumLibrary.Page Should Contain Element    <%= $($_.selector.type) %>:<%= $($_.selector.'#text') %>
<% } -%>
<%= if( $($_.selector.action) -eq "hover") { -%>
<%= $($_.component) %> [- <%= $($_.dialog) %>] - <%= $($_.name) %> Hover
    Run Keyword And Continue On Failure    SeleniumLibrary.Mouse Over                <%= $($_.selector.type) %>:<%= $($_.selector.'#text') %>
<% } -%>
<%= if( $($_.selector.action) -eq "text") { -%>
<%= $($_.component) %> [- <%= $($_.dialog) %>] - <%= $($_.name) %> Check Text
    [arguments]     ${text}	
    Run Keyword And Continue On Failure    SeleniumLibrary.Element Should Contain    <%= $($_.selector.type) %>:<%= $($_.selector.'#text') %>    ${text}    ignore_case=True
<%= $($_.component) %> [- <%= $($_.dialog) %>] - <%= $($_.name) %> Get Text
    ${value}    SeleniumLibrary.Get Text                                             <%= $($_.selector.type) %>:<%= $($_.selector.'#text') %>
    [return]        ${value}
<% } -%>
<% } -%>
'@

Confusing description regarding handling of <%%

Hi,

my goal is to do templating of a classic asp page using powershell. Those files usually contain <% and %> at different lines. However, EPS seems to need <%% and %%> being in the same block, at least this was the only constellation which did work for me.

The description however is a little bit unclear on that topic. For me it indicates that <%% and %%> can be used completely apart from each other:
<%% and %%> : are replaced respectively by <% and %> in the output.

Can you give me a hint if I'm doing something stupid with EPS, if there is a bug in the implementation, or if the manual is wrong?

Many Regards

Erratic behavior with PS for Linux

This is quite interesting, with PS 7.3.1 on Linux with EPS 1.0.0.

I found another way to get the templating done, but maybe it'll help someone save time: this doesn't seem to work right.

Import-Module EPS

$t1 = @"
192.168.1.<%= $last %>/24
s<%= $last %>
"@

$last = 127
Invoke-EpsTemplate -Template $t1

Expected:

192.168.1.127/24
s127

Obtained:

  • The first time
192.168.1./24
s
  • The second time
192.168.1.127/24
s127

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.