Skip to content

make()

Static alias for the constructor.

InMemoryPage::make(string $identifier, Hyde\Markdown\Models\FrontMatter|array $matter, string $contents, string $view): static

__construct()

Create a new in-memory/virtual page instance.

The in-memory page class offers two content options. You can either pass a string to the $contents parameter, Hyde will then save that literally as the page's contents. Alternatively, you can pass a view name to the $view parameter, and Hyde will use that view to render the page contents with the supplied front matter during the static site build process.

Note that $contents take precedence over $view, so if you pass both, only $contents will be used. You can also register a macro with the name 'compile' to overload the default compile method.

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,
$page = new InMemoryPage(string $identifier, \Hyde\Markdown\Models\FrontMatter|array $matter, string $contents, string $view): void

getContents()

Get the contents of the page. This will be saved as-is to the output file when this strategy is used.

$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.

In order to make your virtual page easy to use we provide a few options for how the page can be compiled. If you want even more control, you can register a macro with the name 'compile' to overload the method, or simply extend the class and override the method yourself, either in a standard or anonymous class.

$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. If you have the need for a macro to be used for multiple pages, you should create 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