0

New to webdev.

I need to use the same menu on all the pages of new website i'm building but I'm not willing to edit the menu every time a change it in every file.

Is there a simple template engine for javascript or another solution to fix this issue?

2
  • 2
    This problem is usually solved by your web framework, though it's achievable via JavaScript, too. Are you using a web development framework? Commented Feb 14, 2012 at 11:47
  • possible duplicate of HTML code reuse Commented Feb 14, 2012 at 12:03

1 Answer 1

3

If the menu is dynamically constructed via your website, then you're best bet is to use server-side templates.

In PHP you can do:

include("menu.php");

Wherever you need it to display.

In JavaScript, if you need to style the menu, then check out Mustache.JS or similar.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you but at the moment I'm only able to use javascript, I don't have php support.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.