Sweet.apex

  • Docs
  • Tutorials
Docs Menu
  • Sweet.apex Core
    • Transpilation
    • Grammar
    • Command
    • Config
  • Features
    • Action
    • Apex Doc
    • Array Creation
    • Aspect
    • Cast
    • Default Value
    • Enum
    • File
    • Function
    • Identity
    • Injection
    • Lambda
    • Log
    • Mod
    • Not Null
    • Operator
    • Optional
    • Reflection
    • Rethrow
    • Switch
    • Template String
    • Template
    • Script
    • Tagged String
    • Annotation
    • Nullable
    • Var
    • Val
    • Map Access
    • Constructor
    • Transaction
    • Destructure
    • Import Static
    • Pipeline
    • Varargs
    • Patch
    • Import As
  • Plugin Development
    • Feature
    • Test Case

File Guide

File

Feature Overview

This feature converts files to static resources.

Prerequisite

None

Sweet Apex Example

public class FileDemo {
    public static void main() {
        @file(name='beans')
        String content = null;
    }
}

Transpiled Apex

public class FileDemo {
    public static void main() {
        String content = Sweet.readFile('beans');
    }
}

Usage

The source directories and destination directories of the files are controlled by fileSrcDir and fileDestDir in the config.

When you need to use a file, you can create one in the file source directory. Sweet.apex will compile it to a static resource.

You need to deploy the static resource to make the code work.

Contribute on Github! Edit this section.