Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Functions/Public/base.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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



}

5 changes: 3 additions & 2 deletions Functions/Public/blockquote.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -28,7 +29,7 @@ Function blockquote {
#>
[Cmdletbinding()]
Param(
[Parameter(Mandatory=$true)]
[Parameter(Mandatory=$false)]
[AllowEmptyString()]
[AllowNull()]
[String]
Expand Down Expand Up @@ -80,7 +81,7 @@ Function blockquote {
}


Set-HtmlTag -TagName $tagname -Attributes $htmltagparams -TagType NonVoid
}
Set-HtmlTag -TagName $tagname -Attributes $htmltagparams -TagType NonVoid
}
}
83 changes: 83 additions & 0 deletions Functions/Public/datalist.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
Function datalist {
<#
.SYNOPSIS
Create a datalist tag in an HTML document.

.DESCRIPTION

The <datalist> tag specifies a list of pre-defined options for an <input> element.

The <datalist> tag is used to provide an "autocomplete" feature on <input> elements. Users will see a drop-down list of pre-defined options as they input data.

Use the <input> element's list attribute to bind it together with a <datalist> 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
}
}
}
1 change: 0 additions & 1 deletion Functions/Public/dl.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Function dl {
[Parameter(Mandatory=$false,position=0)]
[AllowEmptyString()]
[AllowNull()]
[String]
$Content,

[Parameter(Position = 1)]
Expand Down
103 changes: 103 additions & 0 deletions Functions/Public/option.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
Function option {
<#
.SYNOPSIS
Create a <option> tag in an HTML document.

.DESCRIPTION

The <option> tag defines an option in a select list.

<option> elements go inside a <select> or <datalist> element.


.EXAMPLE


datalist {
option -value "Volvo" -Content "Volvo"
option -value Saab -Content "saab"
}


Generates the following code:

<datalist>
<option value="Volvo" >volvo</option>
<option value="Saab" >saab</option>
</datalist>


.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()]
$Content,

[string]$value,

[string]$label,

[Switch]$Disabled,

[Switch]$Selected,

[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 = "option"

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
}
}

14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.


65 changes: 65 additions & 0 deletions Tests/datalist.tests.ps1
Original file line number Diff line number Diff line change
@@ -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 '^<datalist.*>' | should be $true
$string -match '.*</datalist>$' | should be $true

}

it "Testing content in child element"{
$string -match "^.*>woop<.*" | should be $true
}

it "Testing common parameters: Class"{
$string -match '^<datalist.*class="myclass".*>' | should be $true
}
it "Testing common parameters: ID"{
$string -match '^<datalist.*id="myid".*>' | should be $true
}
it "Testing common parameters: Style"{
$string -match '^<datalist.*style=".+".*>' | should be $true
}

it "Testing Attributes parameters"{

foreach($at in $CustomAtt.Keys){
$val = $null
$val = $CustomAtt[$at]
$string -match "^<datalist.*$at=`"$val`".*>" | should be $true
}


}


}

}

Pop-Location
Loading