module Spark::Template

Overview

Spark::Template facilitates the ability to run Crystal code from a local or remote file.

USE WITH CAUTION. We do not check file contents before evaluating.

Say you have a file with Crystal code you'd like to run that looks like this:

# /tmp/my_crystal_code.cr
prompt = Spark::Prompt.new
prompt.say "Hello, from my Crystal file!"

You could run that code like this:

Spark::Template.run_local_file("/tmp/my_crystal_code.cr")

Extended Modules

Defined in:

spark/template.cr

Instance Method Summary

Instance Method Detail

def run_local_file(file_path : String, apply_prefix_content : Bool = true, output : IO::FileDescriptor = STDOUT) #

Execute the Crystal code at a given local file path.

USE WITH CAUTION. We do not check file contents before evaluating.

Example:

Spark::Template.run_local_file("/tmp/my_crystal_file.cr")

[View source]
def run_remote_file(url : String, apply_prefix_content : Bool = true, output : IO::FileDescriptor = STDOUT) #

Execute the Crystal code at a given remote URL.

USE WITH CAUTION. We do not check file contents before evaluating.

Example:

Spark::Template.run_remote_file("https://railsbytes.com/script/Xg8sya")

[View source]