New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

adamgaskins/view-string

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

adamgaskins/view-string

The view() helper's little brother; a function to compile blade views from strings.

Source
Packagist
This package is abandoned and is no longer maintained.
The author recommends using Laravel 9's Blade::render() instead.
This version has been yanked by its maintainers and should not be used.
Version
v1.3.0
Version published
Total downloads
3K
Maintainers
1
Created
Source

The view() helper's little brother; a function to compile blade views from strings.

Installation

You can install the package via composer:

composer require adamgaskins/view-string

Usage

This package allows you to compile a blade template dynamically from a string instead of it being hardcoded in the resources/views folder of your site. Usually this will look like a trusted user (developer/admin) using an embedded editor to write a blade template which is then saved to the database. You can then easily render the template like so:

$design = Design::find(1);

view_string($design->content, [ 'blogPost' => $post ]);

Or if you want to include it in your blade templates, there's a directive for that:

@includeString($design->content [ 'blogPost' => $post ])

Use view_string where you'd use view, and @includeString where you'd use @include.

eval

This package uses eval behind the scenes. It is not sandboxed. The goal of this package is to allow developers to write small blade snippets without needing to deploy. I am not responsible for what happens if you let random strangers on the internet run code on your servers.

We use this package at my company to allow us to quickly write tiny snippets of custom elements for our customers, saving us the need to do a full site deploy every time a user requests a change.

Testing

composer test
  • wpb/string-blade-compiler: A great package that I used for years, and inspired this package. A little bit more opinionated though, the fact that it completely replaces Illuminate\View\View leads to issues in some random edge cases.

License

The MIT License (MIT). Please see License File for more information.

Keywords

view

FAQs

Package last updated on 03 May 2022

Related posts