0
   

How do I define a constant of entity in in HTML?

 
 
Muarck
 
Reply Sat 22 Dec, 2012 10:41 pm
I have a bunch of webpages I'm editing that have various text strings recurring through out the page... I don't want to have to retype every appearance of the text when it changes cause from page to page it changes a lot.
As an example, I tried:
<!ENTITY person "John Doe">
<h3>&person;</h3>
<p>your name is &person;</p>
But it didn't work. How do I make something like this work? I don't care if the syntax is wildly different or it doesn't use the entity concept. I just really want to be able to create a "text constant".
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Question • Score: 0 • Views: 1,437 • Replies: 4
No top replies

 
Thomas
 
  2  
Reply Sat 22 Dec, 2012 11:22 pm
@Muarck,
I don't think you can do this in HTML, which is a markup language, not a programming language. I think what you want to do is write the page with your programming language of choice, and define the variable in that language. For example, here's how I might do it in Python:

Code:person = "John Doe"
print("<h3>", person, "</h3>\n"
"<p> your name is", person, "</p>")

Perhaps I can give you a better answer if you give some more specifics. For example, are you just looking for a shortcut in creating static webpages? Or are you looking to create an interactive, dynamic webpage? (In the latter case, you probably want to embed a piece of Javascript in your HTML.) What programming languages are you familiar with? What is operating system does your webserver run on, and what kind of access do you have to it?
Muarck
 
  1  
Reply Tue 25 Dec, 2012 07:43 pm
@Thomas,
I don't need a "variable". I want a static constant which I declare as some value once. Like a constant in VB.
maxdancona
 
  1  
Reply Tue 25 Dec, 2012 10:52 pm
@Muarck,
There is nothing like that in HTML. You can embed Javascript in HTML which is where I would start if I wanted to do something like this client side. It is hard to design it without knowing exactly what you are trying to do.

Generally when a professional wants to write something like this, they will either use a template feature on the server side (i.e. JSPs in Java or PHP templates), or a client side javascript library (e.g. jquery or backbone).


0 Replies
 
Thomas
 
  1  
Reply Tue 25 Dec, 2012 11:08 pm
@Muarck,
Although that's a perfectly reasonable thing for you to want, HTML has no obligation to give it to you. And to the best of my knowledge, it doesn't. To get done what you want done, you'll need to enlist the help of some programming language. I gave you an example using Python. Maxdancona's JavaScript suggestion makes sense, too.

On a broader note, there's no use in telling us what you need from a language. We can't rewrite the language definition for you. But maybe we can help you accomplish your task. So why don't you tell us what your task is?
0 Replies
 
 

Related Topics

 
  1. Forums
  2. » How do I define a constant of entity in in HTML?
Copyright © 2019 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 08/17/2019 at 12:34:11