Skip to content

Commit

Permalink
Merge pull request #222 from tbotaq/enable-syntax-highlight-for-yaml
Browse files Browse the repository at this point in the history
docs: Enable syntax highlight for YAML examples.
  • Loading branch information
kbrock committed Apr 1, 2021
2 parents 8d780d7 + 3f53e77 commit 3f4efb6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ end
The above example will look for the file "/u/data/sample.yml".

Since ActiveYaml just creates a hash from the YAML file, you will have all fields specified in YAML auto-defined for you. You can format your YAML as an array, or as a hash:
```
```yaml
# array style
- id: 1
name: US
Expand Down Expand Up @@ -382,7 +382,7 @@ end

Aliases can be used in ActiveYaml using either array or hash style by including `ActiveYaml::Aliases`.
With that module included, keys beginning with a '/' character can be safely added, and will be ignored, allowing you to add aliases anywhere in your code:
```
```yaml
# Array Style
- /aliases:
soda_flavor: &soda_flavor
Expand All @@ -408,7 +408,8 @@ coke:
name: Coke
flavor: *soda_flavor
price: *soda_price
```
```ruby
class Soda < ActiveYaml::Base
include ActiveYaml::Aliases
end
Expand All @@ -422,7 +423,7 @@ Soda.first.price # => 1.0

Embedded ruby can be used in ActiveYaml using erb brackets `<% %>` and `<%= %>` to set the result of a ruby operation as a value in the yaml file.

```
```yaml
- id: 1
email: <%= "user#{rand(100)}@email.com" %>
password: <%= ENV['USER_PASSWORD'] %>
Expand Down

0 comments on commit 3f4efb6

Please sign in to comment.