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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:48:19+00:00 2026-05-26T20:48:19+00:00

I am working on a project using sinatra with haml for templates. I want

  • 0

I am working on a project using sinatra with haml for templates. I want to be able to append some of my haml partials using JQuery. I am hoping to add this to a js function being triggered by an event like so

....addEventListener(myWidget, 'click', function() {
    $('targetDiv').append(RenderHamlTempalte('/my/file/location/');
});

or

....addEventListener(myWidget, 'click', function() {
    $('targetDiv').append(RenderHamlTempalte('/my/file/location/', {options: here, options: here);
});

I have checked out a few related projects on github but really can’t find something to do this with properly.

thanks for any info

UPDATE:

here was what I ended up going with

var url = '/update&my&div/' + param;
$('.my-div').load(url);

and then in my sinatra app.rb I can just return my haml partial

get ''/update&my&div/:params' do
    # do some stuff
    @make_variables_happen
    haml :my_partial
end
  • 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-26T20:48:20+00:00Added an answer on May 26, 2026 at 8:48 pm

    One way to do this is to use a tool like: https://github.com/uglyog/clientside-haml-js
    You would have to wrap your partials in <script type="text/haml-template" id="template_id"> YOUR PARTIAL GOES HERE </script> and append them somewhere in your html page (I usually add them at the bottom of the page). You can then reference them from JavaScript with:

     var tmpl = haml.compileHaml('template_id');
    

    and then you can pass the data with:

    var html = tmpl({option1: value1, option1: value1});
    

    or based on your example:

    $('targetDiv').append(tmpl({option1: value1, option1: value1}));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a project using Windows 2008, .NET 3.5 and WCF for some
I'm working on a ruby project using Sinatra as a framework and have a
I am working on a project using JavaMail. I want to access my Gmail
I'm working on a project using OpenCV on template matching, and I want to
I am working on a project using iOS3.2 SDK and also want to test
I am working on a project using the uploadify jquery plugin and CastleProject Monorail
I'm working on a project using Java RMI. This is the class causing problem:
I was working on some project using webrat and cucumber (rails 3), so I
I am working on a project using Visual Studio(c#). I want to create a
I'm working on a project using C++. I want a TimerHandler to be called

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.