make()#
Static alias for the constructor.
/** @param string|Closure(static): string $contents */
InMemoryPage::make(string|Closure(static): string, Hyde\Markdown\Models\FrontMatter|array $matter, Closure|string $contents, string $view): static
__construct()#
Create a new in-memory/virtual page instance.
The in-memory page class offers three content strategies. You can pass a literal string, or closure to the $contents parameter, or pass a view name or Blade file to the $view parameter. Closures return strings and are invoked during compile time. We inject page instance as their first argument.
Configured contents take precedence over a view, including closures that return an empty string.
If the identifier for an in-memory page is "foo/bar" the page will be saved to "_site/foo/bar.html". You can then also use the route helper to get a link to it by using the route key "foo/bar". Take note that the identifier must be unique to prevent overwriting other pages. all this data will be passed to the view rendering engine.
- Parameter $view: The view key or Blade file for the view to use to render the page contents.
- Parameter $matter: The front matter of the page. When using the Blade view rendering option,
- Parameter string: $contents Literal page contents or a closure that lazily generates them.
$page = new InMemoryPage(string $identifier, \Hyde\Markdown\Models\FrontMatter|array $matter, string $view, string|Closure(static): string): void
getContents()#
Get the literal contents or invoke the configured content closure with the current page as its first argument.
$page->getContents(): string
getBladeView()#
Get the view key or Blade file for the view to use to render the page contents when this strategy is used.
$page->getBladeView(): string
compile()#
Get the contents that will be saved to disk for this page.
Configured literal or closure contents take precedence over Blade views. A view is rendered only when the configured contents are the empty string. Instance macros do not override this method. Extend this class and override the method for complete control.
$page->compile(): string
macro()#
Register a macro for the instance.
Unlike most macros you might be used to, these are not static, meaning they belong to the instance. Macros add methods that do not already exist on the page. If you have the need for a macro to be used for multiple pages, you should consider creating a custom page class instead.
$page->macro(string $name, callable $macro): void
hasMacro()#
Determine if a macro with the given name is registered for the instance.
$page->hasMacro(string $method): bool
__call()#
Dynamically handle macro calls to the class.
$page->__call(string $method, array $parameters): mixed