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 6896019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:58:54+00:00 2026-05-27T06:58:54+00:00

I am using erb and ideally, I would like my html to look like

  • 0

I am using erb and ideally, I would like my html to look like this:

<li class="selected"><a href="awesome.html">Look at this awesome page</a></li>

Where both the path for the link, and the class for the li are dynamically generated using an instance variable.

Thoughts?

Edit 1

If I were using something like Rails, I know I could probably do something like:

<%= link_to content_tag(:li, nil, awesome_path, :class => "selected") %>

But that would produce the opposite effect, where the <a> would be outside of the <li> and not inside where I want it.

  • 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-27T06:58:55+00:00Added an answer on May 27, 2026 at 6:58 am

    That’s called a helper:

    helpers do
        def li_with_a options
            '<li class="' + options[:class] + '"><a href="' + options[:url] + '">' + options[:text] + '</a></li>'
        end
    end
    

    and from erb:

    <%= li_with_a :class => 'selected', :url => 'awesome.html', :text => 'Look at this text' %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the following tags in my html.erb to both display and download a
I am using rails beta 3 and I have a erb page named index.html.erb
I am creating a select box for a form using this in _form.html.erb <%=
Using Flex 3, I would like to take an image snapshot such as this:
So I'm using an application.html.erb file which is basically the layout for every page
While using Rails ActionMailer with Multipart Emails I created both: approve_trade_email.html.erb AND approve_trade_email.text.erb I
I'm building a blog using RoR. I have the index.html.erb page for the posts
Using a restful resource in Rails, I would like to be able to insert
I'm using application.html.erb in the views/layouts folder of my Ruby on Rails web app
I have a Javascript where I render a partial using the js.erb : $('#registration-steps').fadeOut(fast).html(<%=

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.