Skip to content

Conversation

@spaelling
Copy link
Contributor

Added functions so that one can do links and images using below input.

This allows for more complex input than replacing URLx in a string.

It also makes it fairly easy to make an image link (param4)

Before calling ConvertTo-Html all input properties that are PSCustomObject are replaced with a guid. After the conversion the html is rendered and the guid is replaced.

$ArrayOfObjects = New-Object 'System.Collections.Generic.List[System.Object]'

$obj = [PSCustomObject]@{
    param1 = [PSCustomObject]@{
        _type = 'img'
        src = 'http://ihavecat.com/wp-content/uploads/2014/01/cat-asking-for-help-2.jpg'
        alt = 'cat asking for help'
        width = 60
        height = 60
    }
    param2 = [PSCustomObject]@{
        _type = 'link'
        url = 'https://www.w3schools.com'
        target = '_blank'
        Content = 'Visit w3schools!'
    }
    param3 = 'simpleparam'
    param4 = [PSCustomObject]@{
        _type = 'link'
        url = 'http://ihavecat.com/wp-content/uploads/2014/01/cat-asking-for-help-2.jpg'
        target = '_blank'
        Content = [PSCustomObject]@{
            _type = 'img'
            src = 'http://ihavecat.com/wp-content/uploads/2014/01/cat-asking-for-help-2.jpg'
            alt = 'cat asking for help'
            width = 60
            height = 60
        }
    }
}
$ArrayOfObjects.Add($obj)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant