Stephanevg / PSHTML

Cross platform Powershell module to generate HTML markup language
https://pshtml.readthedocs.io/en/latest/
Other
165 stars 43 forks source link

Add posibility to write asset as content #307

Open Stephanevg opened 2 months ago

Stephanevg commented 2 months ago

Write-PshtmlAsset will write the asset as file. Add parameter -AsContent to write the contents of the asset directly in the html document instead of the link element.

Details

Assets/JessAssets/JessCssfile.css contents:

table.paleBlueRows {
  font-family: "Times New Roman", Times, serif;
  border: 1px solid #FFFFFF;
  width: 350px;
  height: 200px;
  text-align: center;
  border-collapse: collapse;
}

Example:

Write-PSHTMLAsset -Name "JessAssets"

will add the following in the html document:

<Link rel='stylesheet' type=text/css href='C:/PathToScriptFolder/Assets/JessAssets/JessCssFile.css' >

This works well for cases where these files are available (for webpages or static pages where the folder structure is presenent and accesible). But for cases where the html page should be sent per email for example, or when the files are not accessible anymore, it would be interessting to have the possibility to write the full content directly into the html document.

cases

.css files

.css files should be outputed into a styles element. like this

<style>
  table.paleBlueRows {
    font-family: "Times New Roman", Times, serif;
    border: 1px solid #FFFFFF;
    width: 350px;
    height: 200px;
    text-align: center;
    border-collapse: collapse;
  }
</style>

.js

.js files (Asset of type script) shall be exported in a script element as followed

<script>
 //Scriptfile content here
</script
jpomfret commented 2 months ago

Oh neat - this would be awesome!