npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jph

v1.0.8

Published

JavaScript Hypertext Preprocessor

Downloads

3

Readme

EN / RU

jph

GitHub | NpmJS

jph

JavaScript Hypertext Preprocessor

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
  <title>New project</title>
  <link rel="stylesheet" href="style.css">
</head>
<?
  var fileName = ($_REQUEST.path === '/') ? 'home' : $_REQUEST.path.slice(1)
?>
<body id="<? fileName ?>">
  <aside class="menu">
    <nav class="menu__wrapper">
      <a href="/">Home</a>
      <a href="/about">About</a>
      <a href="/contacts">Contacts</a>
    </nav>
  </aside>

  <header class="header">
    <div class="header__wrapper">
      <img class="header__banner" src="img/banner.jpg" alt="banner">
    </div>
  </header>

  <main class="content">
    <div class="content__wrapper">
      <? include('includes/' + fileName + '.html') ?>
    </div>
  </main>
  
  <footer class="footer">
    <p class="footer__wrapper">
      <small>Lorem, ipsum dolor sit amet consectetur adipisicing.</small>
    </p>
  </footer>
</html>

Install

npm i

Start

node index

Site files are located in the htdocs directory. The main site file is called index.html.

The executable JavaScript code is located between special tags:

<?
  var number = 10
?>

The last expression between the special tags is returned to the HTML content, for example:

<div>
  <?
    var number = 10
    number + 6 // return value 16
  ?>
</div>

If you do not want to return the value of the expression, then you must add an empty string before the closing characters of the tags:

<div>
  <?
    var number = 10
    number + 6
  ''?> // an empty string is returned
</div>

If the return value is undefined, then an empty string will be returned instead:

<div>
  <?
    var number = 10 // an empty string is returned
  ?>
</div>

Variables declared with the var keyword are available in any special tags within the same file.

Variables declared with the const or let keywords are only accessible within the special tags within which they were declared:

<?
  var a = 1 // available within file
  let b = 2 // available within tags
  const c = 3 // available within tags
?>

To exchange data between different files, a special $GLOBALS object is used, as shown below:

<?
  $GLOBALS.age = 28 // available within application
?>

To access the request object, the $_REQUEST global variable is used, for example:

<?
  var fileName = ($_REQUEST.path === '/') ? 'home' : $_REQUEST.path.slice(1)
?>

To include HTML files, use the include() function with one argument:

<? include('includes/' + fileName + '.html') ?>

By default, the server runs in fancy URLs mode. Access to the pages of the site is formed dynamically, through access to the main file index.html.

To switch the server to static mode, start the server with the command:

node index static

or explicitly change the value of the FancyURLs constant to false in the index.js file, as shown below:

const FancyURLs = false // includes fancy URLs