Registry / serialization / lodash._reinterpolate

lodash._reinterpolate

JSON →
library3.0.0jsnpmunverified

lodash._reinterpolate is a specialized, internal standalone module designed to expose the regular expression used by Lodash's templating engine for identifying and extracting interpolation delimiters (e.g., `<%= variable %>`). This package is strictly versioned at 3.0.0, aligning it with the Lodash v3 major release. As such, it has not received updates since its initial publication and is considered abandoned for direct consumption in contemporary JavaScript development environments. While the underlying `reInterpolate` regex pattern remains integral to the actively maintained `lodash` (currently v4.18.1) and `lodash-es` distributions' `_.template` function, developers are strongly advised against directly importing or relying on `lodash._reinterpolate`. Instead, the recommended approach is to leverage the robust and publicly exposed `_.template` method from the main Lodash library, which encapsulates and manages this internal logic.

npm install lodash._reinterpolate
INSTALL
IMPORT
SIG · LODASH._REINTERPOL
L
lodash._reinterpolate
serializationjavascriptv3.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

reInterpolate
const reInterpolate = require('lodash._reinterpolate');
import reInterpolate from 'lodash._reinterpolate';
This package is CommonJS-only and frozen at version 3.0.0. It is incompatible with native ES module `import` syntax. Direct usage is largely superseded by using `_.template` from the main lodash package.
template (from main lodash)
import _ from 'lodash'; const compiled = _.template('Hello <%= user %>!');
import { template } from 'lodash._reinterpolate';
The `reInterpolate` regex is an internal implementation detail of `_.template` in modern Lodash (v4+) and `lodash-es`. It is not directly exported as a public symbol. Use the `_.template` function from the main `lodash` package.
template (from modular lodash)
import template from 'lodash/template';
import { template } from 'lodash/template';
When using modular builds (e.g., `lodash/template`), `template` is typically a default export. Ensure your build configuration correctly handles modular `lodash` imports to avoid issues with internal dependencies.

Demonstrates importing the `reInterpolate` regex and how it identifies interpolation patterns within a string, highlighting its internal role in Lodash's templating engine. This raw regex is used by the `_.template` function.

const reInterpolate = require('lodash._reinterpolate'); // The reInterpolate regex is designed to match default Lodash interpolation delimiters. // For example, it finds content within <%= ... %>. const templateContent = 'User ID: <%= user.id %>\nName: <%= user.name.toUpperCase() %>\nLocation: <% location %>'; let match; const matches = []; // Use a global regex to find all matches // Note: reInterpolate itself is not global, so we create a new global instance. const globalReInterpolate = new RegExp(reInterpolate.source, 'g'); while ((match = globalReInterpolate.exec(templateContent)) !== null) { // match[0] is the full matched string (e.g., '<%= user.id %>') // match[1] is the content inside the delimiters (e.g., 'user.id') matches.push({ full: match[0], content: match[1] }); } console.log('Detected interpolation tokens:'); matches.forEach(m => console.log(`Full Match: '${m.full}', Content: '${m.content}'`)); // In a real scenario, this regex is used internally by _.template. // For modern usage, you'd use lodash.template directly: // const _ = require('lodash'); // or import _ from 'lodash'; // const compiled = _.template('Hello <%= user.name %>!'); // console.log(compiled({ user: { name: 'World' } }));
Debug
Known issues
breakingThis `lodash._reinterpolate` package is fixed at v3.0.0 and corresponds to Lodash v3. Lodash v4.0.0 introduced significant breaking changes across the entire library. Directly using this v3 module with a modern Lodash v4+ environment may lead to unexpected behavior or incompatibilities, as internal assumptions might have changed.
fix
Avoid direct usage of internal modules like `lodash._reinterpolate`. Migrate to using the official `_.template` method from the main `lodash` or `lodash-es` packages, which internally handles the `reInterpolate` logic and is compatible with your Lodash version.
affects: >=4.0.0 (of main lodash)
gotchaThis package (`lodash._reinterpolate`) is an internal Lodash module and not part of its public API. It is not intended for direct public consumption. Its API is unstable, not guaranteed by semantic versioning for standalone modules, and relying on its direct import can lead to brittle code that breaks with minor `lodash` updates.
fix
Always use the public `_.template` API from the main `lodash` or `lodash-es` package to generate compiled templates, as this is the officially supported and stable way to utilize templating functionality.
affects: All versions
gotchaThe `lodash` library experienced a `ReferenceError` issue in `lodash.template` within version 4.18.0 (and related modular builds). While this `_reinterpolate` module is v3.0.0, issues in the templating engine of later `lodash` versions can indirectly affect how its internal regex is consumed or how compiled templates behave.
fix
Ensure your main `lodash` dependency is updated to at least `4.18.1` to mitigate template-related `ReferenceError` issues.
affects: lodash@4.18.0
Errors
Common errors & fixes
ReferenceError: templateSettings is not defined
This error specifically occurred in `lodash@4.18.0` and modular `lodash.template` builds due to internal dependency mapping issues during the build process.
fix
Upgrade your main `lodash` dependency to `lodash@4.18.1` or higher. This specific error is unlikely to originate directly from `lodash._reinterpolate@3.0.0` but from a newer `_.template` implementation.
SyntaxError: The requested module 'lodash._reinterpolate' does not provide an export named 'default'
Attempting to use `import reInterpolate from 'lodash._reinterpolate'` in an ES Module context, but `lodash._reinterpolate` is a CommonJS module that exposes its value via `module.exports` and does not define a `default` export.
fix
If running in a CommonJS environment, use `const reInterpolate = require('lodash._reinterpolate');`. If in an ESM environment, you might be able to use a dynamic `import()` or must rely on the main `lodash` package's `_.template` method which internally uses this regex.
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
lodash._reinterpolate — npm install lodash._reinterpolate · libregistry