> For the complete documentation index, see [llms.txt](https://eucalypt.gitbook.io/eucalypt/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://eucalypt.gitbook.io/eucalypt/features/static-data.md).

# Static data

### Disambiguation

This documentation page is **not** about serving static assets or rendering static files.

* For serving static assets (images, scripts, stylesheets, fonts, etc.) view the [asset pipeline](/eucalypt/features/configuration/asset-pipeline.md) documentation page.
* For rendering other static files, view the [rendering static files](/eucalypt/features/rendering-static-webpages.md) documentation page

### Description

The `static` directory should contain structured data in the YAML, JSON or XML formats. Other files can be stored here for the purpose of [rendering them](/eucalypt/features/rendering-static-webpages.md), but only files of these formats can be accessed.

> Currently supported extensions are: `.xml`, `.yaml`, `.yml`, `.json` and `.geojson`.

The `Static` helper constant can be accessed from anywhere within your application. This constant acts as a link to the `static` directory, allowing you to access data.

### Examples

* The data in a `.geojson` file at `static/server-locations.geojson` can be accessed with:

  ```ruby
  Static.server_locations
  ```

  **NOTE**: The file name is automatically inflected to create a valid Ruby method name. This may lead to differences between the file name and method name as seen in this example (with the `-` being changed to a `_`).

* The data in a `.json` file at `static/dependencies/config.json` can be accessed with:

  ```ruby
  Static.dependencies.config
  ```

  **NOTE**: Directory names are also inflected in the same way as file names.

* The data in a `.yml` file at `static/locales.en.yml` can be accessed with:

  ```ruby
  Static.locales.en
  ```

### Viewing defined sub-directory and file methods

The `Object#methods` method can be used to check for defined sub-directory and file methods for the `Static` helper object.

Consider the following directory structure:

```
static
├── hobbies
│   ├── academic
│   │   └── ruby.yml
│   └── non-academic
│       ├── games
│       │   └── chess.yml
│       └── sports
│           ├── climbing.json
│           └── golf.yml
└── main.yml
```

```ruby
Static.methods(false) #=> [:hobbies, :main]
Static.hobbies.methods(false) #=> [:academic, :non_academic]
Static.hobbies.academic.methods(false) #=> [:ruby]
Static.hobbies.non_academic.methods(false) #=> [:games, :sports]
Static.hobbies.non_academic.games.methods(false)  #=> [:chess]
Static.hobbies.non_academic.sports.methods(false) #=> [:climbing, :golf]
```

### Symbolizing

Data that is read from the files in the `static` directory is automatically converted into a hash.

Since it is Ruby convention that hash keys are symbols, all hash keys accessed through this helper will be symbolized by default (this can be changed in the [core application file](/eucalypt/features/core-application-file.md), however).

#### Examples

Consider the following `.yml` file:

{% code title="app/static/ruby.yml" %}

```yaml
projects:
  frameworks:
    - name: 'Rails'
      repo: 'https://github.com/rails/rails'
    - name: 'Eucalypt'
      repo: 'https://github.com/eucalypt-framework/eucalypt'
```

{% endcode %}

If configured to symbolize the generated hash, then the data for the `Rails` framework can be accessed with:

```ruby
Static.ruby[:projects][:frameworks].first
#=> {:name=>"Rails", :repo=>"https://github.com/rails/rails"}
```

If configured to **not** symbolize the generated hash, then the data for the `Eucalypt` framework can be accessed with:

```ruby
Static.ruby["projects"]["frameworks"].last
#=> {"name"=>"Eucalypt", "repo"=>"https://github.com/eucalypt-framework/eucalypt"}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://eucalypt.gitbook.io/eucalypt/features/static-data.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
