Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #26256

Re: need to evaluate and store a mustache variable for a date function

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: need to evaluate and store a mustache variable for a date function
Date Sun, 30 Nov 2014 17:45:44 +0100
Organization PointedEars Software (PES)
Lines 42
Message-ID <2856755.Lea29hFERk@PointedEars.de> (permalink)
References <b9ca691a-354d-4eb0-b38c-c697707e99c7@googlegroups.com>
Reply-To Thomas 'PointedEars' Lahn <cljs@PointedEars.de>
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding 8Bit
X-Trace solani.org 1417365946 717 eJwFwYEBgDAIA7CXZKXAzkGk/59gQoTFpAfDKeqMmWyK+XQ78lziwjRbegsLmZOlDMW33j8NohDf (30 Nov 2014 16:45:46 GMT)
X-Complaints-To abuse@news.solani.org
NNTP-Posting-Date Sun, 30 Nov 2014 16:45:46 +0000 (UTC)
User-Agent KNode/4.14.2
X-User-ID eJwNyskBwDAIA7CVSAFTxok59h+h1VuuOKgwOMzXN5+DZnSe9NIZTFJGoDfkYUQza50QMiFrf7gIleoxvIYPV4YVow==
Cancel-Lock sha1:eLG4unJiMpWDQeAwSivCHXn6iag=
X-NNTP-Posting-Host eJwFwQEBACAIA7BKoHIkjsrfP4JbTDheLgRWKNQ3nW8PDTttpI7PrWUlsFnMvih1moc5Gx85ghH3
Xref csiph.com comp.lang.javascript:26256

Show key headers only | View raw


JRough wrote:

> I need the date in another format than JSP and since I don't know Java I
> would like it to be in javascript. I don't know how to store the Mustache
> variable so I can input it into the date function?   I need the filingDate
> value from mustache as input into the date object. thanks,
> 
> 
>  <li class="activity-list {{type}}"><div id="activity-date">  <script>
>    var d = new Date( {{filingDate}}
>    );document.write(d.getMonth(d))</script></div></li>

If “{{filingDate}}” expands to a number specifying the number of seconds or 
milliseconds since Epoch for that date, then you can use that approach 
(seconds would have to be multiplied by 1'000); otherwise, as we have 
determined recently [1], you SHOULD NOT.

If “{{filingDate}}” expands to a string from which you can extract the month 
number, such as "2014-11-30", then you can assign, for example:

  var d = "{{filingDate}}";

and then use string methods to process the value of “d” (also discussed 
recently).

However, it is likely that Mustache has a way to get to the information 
without client-side scripting; it would be better that way, unless you can 
make sure that client-side scripting and document.write() is supported with 
the user.  Still, document.write() should be avoided as it slows down 
rendering of the document; tree-modifying methods introduced with the W3C 
DOM should be used instead.

Mustache is off-topic here, though, as you have been told before.  Please 
read and follow the recommendations in the FAQ.  And get a real name.

_______
[1] <news:0d947d29-c683-4417-b081-983f18bb11bf@googlegroups.com>
-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

need to evaluate and store a mustache variable for a date function JRough <janis.rough@gmail.com> - 2014-11-29 13:57 -0800
  Re: need to evaluate and store a mustache variable for a date function Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-11-30 17:45 +0100

csiph-web