Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 624577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:12:55+00:00 2026-05-13T19:12:55+00:00

Is there a custom tag in YAML for ruby to include a YAML file

  • 0

Is there a custom tag in YAML for ruby to include a YAML file inside a YAML file?

#E.g.:  
--- !include
filename: another.yml

A similar question was asked some time ago and there was no relevant answer.

I am wondering if there is some custom tag for Ruby similar to this one for Python.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T19:12:56+00:00Added an answer on May 13, 2026 at 7:12 pm

    I found a way to address my scenario using ERB.

    I monkey patched YAML module to add two new methods

    module YAML
        def YAML.include file_name
          require 'erb'
          ERB.new(IO.read(file_name)).result
        end
    
        def YAML.load_erb file_name
          YAML::load(YAML::include(file_name))
        end  
    end
    

    I have three YAML files.

    mod1_config.yml

    mod1:
        age: 30
        city: San Francisco
    

    mod2_config.yml

    mod2:
        menu: menu1
        window: window1
    

    all_config.yml

    <%= YAML::include("mod1_config.yml") %>
    <%= YAML::include("mod2_config.yml") %>
    

    Parse the yaml file using the method YAML::load_erb instead of the method YAML::load.

      config = YAML::load_erb('all_config.yml') 
      config['mod1']['age'] # 30
      config['mod2']['menu'] # menu1
    

    Caveats:

    1. Does not support document merge
    2. Last include overwrites same named keys
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In an HTML <label> tag, say there are some custom attributes in the tag
Plain text contains a custom tag that named <code>. Inside a tag there is
I have the following situation: There is one custom view inside of the first
For example, let's say there is a custom template tag {% custom_tag parameter %}
Is there possibility to narrow context for include. For example, I have for tag
I built a custom template tag and I wanna know if there is a
Hi I need to refresh my custom template tag --right_side.py-- via Ajax. Is there
There's precious little documentation about the declare-styleable tag by which we can declare custom
I have a custom tag that does some processing and then sets a cookie.
I am trying to use a variable inside a custom Struts tag something like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.