Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Blade component to read content from anywhere (URLs, base64...) #55

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

felixdorn
Copy link

@felixdorn felixdorn commented Mar 9, 2024

Hi,

Currently,

<x-torchlight-code contents="https://gist.githubusercontent.com/..." />

does not work because of the is_file condition which reduces what we can accept to the file:// wrapper instead of all the stream wrappers.

The above is only one example, here's another, when using Stripe's markdoc.dev, which is not ported to PHP (yet), one can simply convert the fence node (codeblock) to the blade equivalent without messing with the torchlight-cli:

const fence = {
  render 'pre',
  // ...
  transform(node, config) {
      const attributes = node.transformAttributes(config);

      return new Tag('pre', {}, [
          new Tag('x-torchlight-code', {
              language: node.attributes.language,
              "contents": "data://text/plain;base64," + btoa(node.attributes.content)
          }, [])
      ])
    }
}

The <x-torchlight-code contents="data://text/plain;base64,..."> produced then works without any changes, assuming the middleware is registered.

@felixdorn felixdorn changed the title Allow components to read contents from any file handlers Allow Blade component to read content from anywhere (URLs, base64...) Mar 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant