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

  • Home
  • SEARCH
  • 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 8634877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:49:44+00:00 2026-06-12T09:49:44+00:00

When I loop though an IEnumerable in my DotLiquid template {% for block in

  • 0

When I loop though an IEnumerable in my DotLiquid template

{% for block in Blocks -%}

    // this works
    {{ block.Structure }}

    // this doesn't
    {% RenderObject block.Structure %}

{% endfor -%} 

I can render a member directly via block.Structure but I don’t know how to access this Structure object in my own tag class RenderObject:

public class RenderObject : Tag
{
    private string _tagName;
    private string _markup;

    public override void Initialize(string tagName, string markup, List<string> tokens)
    {
        _tagName = tagName;
        _markup = markup.Trim();
        base.Initialize(tagName, markup, tokens);
    }

    public override void Render(Context context, TextWriter result)
    {
        // HERE COMES THE QUESTION
        // How to access the block.Structure object here?
        var structure = ?
  • 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-06-12T09:49:46+00:00Added an answer on June 12, 2026 at 9:49 am

    You can use the context object that’s passed in to your RenderObject.Render method. There’s an indexer on Context that resolves variable names into variables. (And the For tag places the loop variable, i.e. block in your example, into the context.)

    The remaining problem is getting the variable name (“block.Structure”). Fortunately, that’s exactly what the markup variable, passed in to RenderObject.Initialize, is there for.

    So this should work:

    public class RenderObject : Tag
    {
        private string _tagName;
        private string _markup;
    
        public override void Initialize(string tagName, string markup, List<string> tokens)
        {
            _tagName = tagName;
            _markup = markup.Trim();
            base.Initialize(tagName, markup, tokens);
        }
    
        public override void Render(Context context, TextWriter result)
        {
            var structure = context[_markup];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do I get a specific index or loop through this data structure? public
I am trying to loop though my users database to show each username in
I need to write some code that would loop though all rows of a
I'm confused. I'm trying to loop though 2 files looking at the first token
I know I can loop through each character of two NSString objects using characterAtIndex:
I'm trying to loop through objects from my database in the template and one
given this code namespace GridTests { public class Grid<T> { IEnumerable<T> DataSource { get;
i have a data structure like this public class Employee { public string Name
I have a method with an IEnumerable<T> parameter. T can be one of the
Not really a requirement or anything yet, but can you do this in a

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.