From 407897548209622c3aadbb0f5f9d174fca308b42 Mon Sep 17 00:00:00 2001 From: Van Gulick Date: Thu, 4 Oct 2018 23:46:57 +0200 Subject: [PATCH 1/7] Update README.md --- README.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e8a60a02..1717d2ec 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Module to generate HTML markup language within a DSL. Usinng PSHTML, offers code completition and syntax highliting from the the default powershell langauge. As PSHTML respects the W3C standards, any HTML errors, will be spotted immediatly. -## A few Basic examples +## A few Basic examples of what PSHTML can achieve ### Basic page @@ -174,13 +174,19 @@ In parallel to this, I want to add the support for the following attributes (as Eventually, the following components will also be added: - - [ ] Scripts - - [ ] Include Sections + - [X] Scripts + - [X] Include Sections - [ ] Interactive Data Each function has an additional parameter called: ```Attributes``` of type HashTable. -It allow to add additional html tags without having to list ALL the existing attributes. It offers flexibility for custom and/or special htmls attributes. +It allow to add additional html tags without having to list ALL the existing attributes. It offers flexibility for custom and/or special htmls attributes, or the ones that are not immediatly available to you. (Open an issue, if you want to have an additional parameter for a specific html element. Or, you could add it your self, since this is an open sourced project ;) (Read 'contributing' part here under. ## HTML 5 coverage I would like to have all HTML 5 tags available in PSHTML ASAP. The list is currently ongoing, and this is work in progress. It can be followed [here](https://github.com/Stephanevg/PSHTML/issues/7) + +## Contributing + +Read how you can `contribute` to `pshtml`by reading the [contributing](.\contributing.md) document. + + From a86e67b360d1edc805442a7b2577e157351c3d34 Mon Sep 17 00:00:00 2001 From: Van Gulick Date: Thu, 4 Oct 2018 23:50:08 +0200 Subject: [PATCH 2/7] Update README.md Added Contributing part --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1717d2ec..9002b3c6 100644 --- a/README.md +++ b/README.md @@ -187,6 +187,6 @@ I would like to have all HTML 5 tags available in PSHTML ASAP. The list is curre ## Contributing -Read how you can `contribute` to `pshtml`by reading the [contributing](.\contributing.md) document. +Read how you can `contribute` to `pshtml`by reading the [contributing](/CONTRIBUTING.md) document. From f0457f57492805e4ef7f22291a4bfc1db57636f4 Mon Sep 17 00:00:00 2001 From: stephanevg Date: Fri, 5 Oct 2018 00:08:31 +0200 Subject: [PATCH 3/7] fixed content mandatory $tre to false --- Functions/Public/blockquote.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Functions/Public/blockquote.ps1 b/Functions/Public/blockquote.ps1 index 651b3975..86bfcf10 100644 --- a/Functions/Public/blockquote.ps1 +++ b/Functions/Public/blockquote.ps1 @@ -28,7 +28,7 @@ Function blockquote { #> [Cmdletbinding()] Param( - [Parameter(Mandatory=$true)] + [Parameter(Mandatory=$false)] [AllowEmptyString()] [AllowNull()] [String] From 1f805e9d66abd75b973550aef7f20dfd6bed97d4 Mon Sep 17 00:00:00 2001 From: stephanevg Date: Fri, 5 Oct 2018 00:18:05 +0200 Subject: [PATCH 4/7] v0.5.18: Added Datalist and tests. --- Functions/Public/datalist.ps1 | 83 +++++++++++++++++++++++++++++++++++ Tests/datalist.tests.ps1 | 65 +++++++++++++++++++++++++++ pshtml.psd1 | 2 +- 3 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 Functions/Public/datalist.ps1 create mode 100644 Tests/datalist.tests.ps1 diff --git a/Functions/Public/datalist.ps1 b/Functions/Public/datalist.ps1 new file mode 100644 index 00000000..b2558090 --- /dev/null +++ b/Functions/Public/datalist.ps1 @@ -0,0 +1,83 @@ +Function datalist { + <# + .SYNOPSIS + Create a datalist tag in an HTML document. + + .DESCRIPTION + + The tag specifies a list of pre-defined options for an element. + + The tag is used to provide an "autocomplete" feature on elements. Users will see a drop-down list of pre-defined options as they input data. + + Use the element's list attribute to bind it together with a element. + + .EXAMPLE + + .EXAMPLE + + + .NOTES + Current version 2.0 + History: + 2018.10.05;@stephanevg;Creation. + .LINK + https://github.com/Stephanevg/PSHTML + #> + [Cmdletbinding()] + Param( + [Parameter(Mandatory=$false)] + [AllowEmptyString()] + [AllowNull()] + [String] + $Content, + + [string]$cite, + + [AllowEmptyString()] + [AllowNull()] + [String]$Class="", + + [String]$Id, + + [AllowEmptyString()] + [AllowNull()] + [String]$Style, + + [String]$title, + + [Hashtable]$Attributes + ) + + Process { + + $CommonParameters = "tagname" + [System.Management.Automation.PSCmdlet]::CommonParameters + [System.Management.Automation.PSCmdlet]::OptionalCommonParameters + $CustomParameters = $PSBoundParameters.Keys | ? { $_ -notin $CommonParameters } + + $htmltagparams = @{} + $tagname = "datalist" + + if($CustomParameters){ + + foreach ($entry in $CustomParameters){ + + + if($entry -eq "content"){ + + + $htmltagparams.$entry = $PSBoundParameters[$entry] + }else{ + $htmltagparams.$entry = "{0}" -f $PSBoundParameters[$entry] + } + + + } + + if($Attributes){ + $htmltagparams += $Attributes + } + + + Set-HtmlTag -TagName $tagname -Attributes $htmltagparams -TagType NonVoid + } + } +} \ No newline at end of file diff --git a/Tests/datalist.tests.ps1 b/Tests/datalist.tests.ps1 new file mode 100644 index 00000000..345e464f --- /dev/null +++ b/Tests/datalist.tests.ps1 @@ -0,0 +1,65 @@ +$TestsPath = Split-Path $MyInvocation.MyCommand.Path + +#$FunctionsPath = join-Path -Path (get-item $TestsPath).Parent -ChildPath "Functions" + +$RootFolder = (get-item $TestsPath).Parent + +Push-Location -Path $RootFolder.FullName + +set-location -Path $RootFolder.FullName + +Write-Verbose "Importing module" + +import-module .\PSHTML -Force + +Context "Testing PSHTML"{ + Describe "Testing datalist" { + + + $Class = "MyClass" + $Id = "MyID" + $Style = "Background:green" + $CustomAtt = @{"MyAttribute1"='MyValue1';"MyAttribute2"="MyValue2"} + $string = datalist {woop} -Attributes $CustomAtt -Style $Style -Class $class -id $id + + if($string -is [array]){ + $string = $String -join "" + } + + it "Should contain opening and closing tags" { + $string -match '^' | should be $true + $string -match '.*$' | should be $true + + } + + it "Testing content in child element"{ + $string -match "^.*>woop<.*" | should be $true + } + + it "Testing common parameters: Class"{ + $string -match '^' | should be $true + } + it "Testing common parameters: ID"{ + $string -match '^' | should be $true + } + it "Testing common parameters: Style"{ + $string -match '^' | should be $true + } + + it "Testing Attributes parameters"{ + + foreach($at in $CustomAtt.Keys){ + $val = $null + $val = $CustomAtt[$at] + $string -match "^" | should be $true + } + + + } + + + } + +} + +Pop-Location \ No newline at end of file diff --git a/pshtml.psd1 b/pshtml.psd1 index cf0bf4e5..9fb1d460 100644 --- a/pshtml.psd1 +++ b/pshtml.psd1 @@ -12,7 +12,7 @@ RootModule = 'pshtml.psm1' # Version number of this module. -ModuleVersion = '0.5.17' +ModuleVersion = '0.5.18' # Supported PSEditions # CompatiblePSEditions = @() From 3f1a1f2c5fa651dc852c115f6a16f8dd41b21f7b Mon Sep 17 00:00:00 2001 From: stephanevg Date: Fri, 5 Oct 2018 00:32:51 +0200 Subject: [PATCH 5/7] Fixed blockquote when no params are passed --- Functions/Public/blockquote.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Functions/Public/blockquote.ps1 b/Functions/Public/blockquote.ps1 index 86bfcf10..3a65626c 100644 --- a/Functions/Public/blockquote.ps1 +++ b/Functions/Public/blockquote.ps1 @@ -20,6 +20,7 @@ Function blockquote { .NOTES Current version 2.0 History: + 2018.10.02;@stephanevg;Fixed error when no content passed. to version 2.0 2018.10.02;bateskevin;updated to version 2.0 2018.05.07;stephanevg;updated to version 1.0 2018.04.01;bateskevinhanevg;Creation. @@ -80,7 +81,7 @@ Function blockquote { } - Set-HtmlTag -TagName $tagname -Attributes $htmltagparams -TagType NonVoid } + Set-HtmlTag -TagName $tagname -Attributes $htmltagparams -TagType NonVoid } } \ No newline at end of file From c475adbda0ccadf30d233c7dc87f0440a033f3d5 Mon Sep 17 00:00:00 2001 From: stephanevg Date: Fri, 5 Oct 2018 01:38:22 +0200 Subject: [PATCH 6/7] Fixed dl when content = "" --- Functions/Public/dl.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/Functions/Public/dl.ps1 b/Functions/Public/dl.ps1 index b7ec62fc..808869a3 100644 --- a/Functions/Public/dl.ps1 +++ b/Functions/Public/dl.ps1 @@ -27,7 +27,6 @@ Function dl { [Parameter(Mandatory=$false,position=0)] [AllowEmptyString()] [AllowNull()] - [String] $Content, [Parameter(Position = 1)] From f63d43874abd9b8c8b64b76885bb1af1e931232f Mon Sep 17 00:00:00 2001 From: stephanevg Date: Fri, 5 Oct 2018 02:07:33 +0200 Subject: [PATCH 7/7] Added option + tests + fix sur base --- Functions/Public/base.ps1 | 7 ++- Functions/Public/option.ps1 | 103 ++++++++++++++++++++++++++++++++++++ Tests/option.tests.ps1 | 74 ++++++++++++++++++++++++++ 3 files changed, 182 insertions(+), 2 deletions(-) create mode 100644 Functions/Public/option.ps1 create mode 100644 Tests/option.tests.ps1 diff --git a/Functions/Public/base.ps1 b/Functions/Public/base.ps1 index 0862eaa4..e77426cd 100644 --- a/Functions/Public/base.ps1 +++ b/Functions/Public/base.ps1 @@ -63,10 +63,13 @@ Function base { } - Set-HtmlTag -TagName $tagname -Attributes $htmltagparams -TagType nonVoid + if($Attributes){ + $htmltagparams += $Attributes + } + } + Set-HtmlTag -TagName $tagname -Attributes $htmltagparams -TagType nonVoid } - diff --git a/Functions/Public/option.ps1 b/Functions/Public/option.ps1 new file mode 100644 index 00000000..ba9283e5 --- /dev/null +++ b/Functions/Public/option.ps1 @@ -0,0 +1,103 @@ +Function option { + <# + .SYNOPSIS + Create a