AdonisJS API
    Preparing search index...

    The Stub class processes template files using the Tempura template engine to generate code files. Stubs are template files that contain placeholders and logic for generating application resources like controllers, models, etc.

    Features:

    • Tempura template processing with data binding
    • Automatic file writing with directory creation
    • Force overwrite support
    • Export metadata parsing from template output
    • Enhanced error reporting with stub file locations
    const stub = new Stub(app, stubContent, '/path/to/controller.stub')
    const result = await stub.generate({
    name: 'UserController',
    to: app.httpControllersPath('user_controller.ts')
    })
    Index
    • Creates a new Stub instance for processing template files.

      Parameters

      • app: Application<any>

        The application instance

      • stubContents: string

        The raw contents of the stub template

      • stubPath: string

        The absolute path to the stub file

      Returns Stub

    • Replaces the rendered stub output with raw content. When called, the provided content will be used as the final output instead of processing the stub template.

      Parameters

      • rawContent: string

        The raw content to use instead of rendering the stub

      Returns Stub

      Returns the Stub instance for method chaining

    • Prepares the stub for file generation by rendering the template and extracting all metadata, without actually writing to disk.

      Parameters

      • stubData: Record<string, any>

        The data to use for stub preparation

      Returns Promise<PreparedStub>

    • Generates the final resource file by processing the stub template and writing the result to disk, with support for force overwrite.

      Parameters

      • stubData: Record<string, any>

        The data to use for stub generation

      Returns Promise<GeneratedStub>