Class: Makit::Cli::Generators::Templates::Node::IndexJs

Inherits:
Object
  • Object
show all
Defined in:
lib/makit/cli/generators/templates/node_templates.rb

Overview

Template generator for Node.js index.js entry point files

Generates a simple JavaScript file that outputs “Hello, World!” to the console. Provides a basic starting point for Node.js applications.

Examples:

index = IndexJs.new("my-app")
js_content = index.render

Instance Method Summary collapse

Constructor Details

#initialize(project_name) ⇒ IndexJs

Initialize a new index.js template generator

Parameters:

  • project_name (String)

    the name of the Node.js project (unused but kept for consistency)



67
68
69
# File 'lib/makit/cli/generators/templates/node_templates.rb', line 67

def initialize(project_name)
  @project_name = project_name
end

Instance Method Details

#renderString

Render the index.js JavaScript content

Returns:

  • (String)

    the complete JavaScript code for the main entry point



74
75
76
77
78
# File 'lib/makit/cli/generators/templates/node_templates.rb', line 74

def render
  <<~JAVASCRIPT
    console.log("Hello, World!");
  JAVASCRIPT
end