Multiple templates in directory with name "Templates"
I think it would be nice when the directory "templates" may contain more then one template. So I created a directory "default" and moved the directories "public" and "views" into it and changed these two function
function Get-PodeWebTemplatePath { param( [Parameter()] $Template )
$path = Split-Path -Parent -Path ((Get-Module -Name 'Pode.Web').Path)
return (Join-PodeWebPath (Join-PodeWebPath $path 'Templates') $Template)
}
function Use-PodeWebTemplates { :::: $Title,
[Parameter()]
[string]
$Template,
::: if ([string]::IsNullOrWhiteSpace($Template)) { $Template = 'default' } $templatePath = Get-PodeWebTemplatePath $template
::: }
Now I am able to create a template clone "mytemplate" in "templates" and in my server.ps1 I can call
Use-PodeWebTemplates -Title 'MyServer' -theme Dark -template mytemplate
Hi @TFischerIntercope,
This looks similar to #309, to add support for custom templates 😄
Hi Badgerati, no, it wasn't about changing an element, but about the structure and content of Index.pode. I didn't quite understand why there can only be a single template in the "templates" directory. Maybe there is a more elegant way to duplicate Index.pode
I didn't quite understand why there can only be a single template in the "templates" directory
Mostly because no one has asked for custom templates until now 😜
By extension this and custom elements are the same; if we add support for custom templates in general then this would allow custom index/login pages, elements, and layouts (and any other template types in the future).
Pode.Web will only ever have its templates in that one directory bundled with the module, but it should be possible to make it so you can have your own templates folder at the root of your server (or elsewhere), and tell Pode.Web to use that instead; and be able to do it on a per page/element/layout basis as well. (possibly even the JS/CSS as well 🤔, and allow for complete custom template packs).