Closed yecril71pl closed 2 years ago
FUNCTION OUT-HTML {
$ARGS. AST. ENDBLOCK | % { IF ($_) {
OUT-HTML $_
}
}
$ARGS. STATEMENTS. PIPELINEELEMENTS | % { $_. EXPRESSION. VALUE
(,$_. COMMANDELEMENTS) | % {} { $_ | % {
IF ($_. STRINGCONSTANTTYPE) {
-JOIN ('<', $_. VALUE)
}
IF ($_. EXPRESSION)
{ $_. EXPRESSION
}
IF ($_. PARAMETERNAME) { -JOIN (' ', $_. PARAMETERNAME, '=', $_. ARGUMENT) }
}
} { IF ($_) {
'>' }
$_. SCRIPTBLOCK. ENDBLOCK | SELECT -LAST 1 | % { OUT-HTML $_
}
IF ($_. SCRIPTBLOCK) {
-JOIN (
'</',
$_. VALUE,
'>')
}
} {}
}
}
Here is how I use it:
OUT-HTML {
HTML -LANG:EN {
META -HTTP-EQUIV:CONTENT-TYPE -CONTENT: 'TEXT/HTML; CHARSET=US-ASCII'
TITLE {
'Some title'
}
P {
'Yadda yadda yadda'
}
}
}
Note: Empty elements like META do not have a block parameter.
Thanks for opening an issue @yecril71pl I actually don't see this as a problem. The nature of the HTML syntax forces us to use another type of naming convention for the functions than the 'recommended (but not required)' verb-noun specification.
Also, there is already 'kind of' a similar private function which does the same as your 'out-html' called 'Set-pshtmltag' (If I recall correctly).
'IF' we would go with adding aliases, we should point them to that function. Nevertheless, I actually don't think it is needed, and I think it is totally ok to have functions called 'a' or 'br' when a module such as pshtml is loaded.
Subject of the issue
The commands published are not PowerShell commands. PowerShell commands should conform to the convention Verb-Object.
Steps to reproduce
Tell us how to reproduce this issue. What is
A
?Expected behaviour
A
should be an alias for commandFORMAT-HTMLANCHOR
.Actual behaviour
A
is a command in modulePSHTML
.