0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-04-08 02:52:39 -05:00

Renamed rendering service to handlebars

- This fits more closely, as this service is to so with rendering helpers and small parts
- Whereas we want to use "rendering" for things concerned with rendering pages
This commit is contained in:
Hannah Wolfe 2022-04-05 17:38:46 +01:00
parent 62058730cd
commit c902d91c81
No known key found for this signature in database
GPG key ID: AB586C3B5AE5C037
43 changed files with 45 additions and 44 deletions

View file

@ -3,7 +3,7 @@
//
// Outputs inline scripts used for analytics
const {settingsCache} = require('../../../../services/proxy');
const {SafeString} = require('../../../../services/rendering');
const {SafeString} = require('../../../../services/handlebars');
function ampComponents() {
let components = [];

View file

@ -9,7 +9,7 @@
// amp-img, amp-ad, amp-embed, amp-video and amp-pixel.
// (less) dirty requires
const {settingsCache} = require('../../../../services/proxy');
const {SafeString} = require('../../../../services/rendering');
const {SafeString} = require('../../../../services/handlebars');
function ampComponents() {
let components = [];

View file

@ -12,7 +12,7 @@ const {DateTime, Interval} = require('luxon');
const errors = require('@tryghost/errors');
const logging = require('@tryghost/logging');
const {SafeString} = require('../../../../services/rendering');
const {SafeString} = require('../../../../services/handlebars');
const amperizeCache = {};
let allowedAMPTags = [];

View file

@ -1,4 +1,4 @@
const {SafeString, escapeExpression} = require('../../../../services/rendering');
const {SafeString, escapeExpression} = require('../../../../services/handlebars');
module.exports = function amp_style(options) { // eslint-disable-line camelcase
if (options.data.site.accent_color) {

View file

@ -4,7 +4,7 @@
// Password input used on private.hbs for password-protected blogs
// (less) dirty requires
const {SafeString, templates} = require('../../../../services/rendering');
const {SafeString, templates} = require('../../../../services/handlebars');
// We use the name input_password to match the helper for consistency:
module.exports = function input_password(options) { // eslint-disable-line camelcase

View file

@ -3,7 +3,7 @@
//
// Returns the path to the specified asset.
const {metaData, urlUtils} = require('../services/proxy');
const {SafeString} = require('../services/rendering');
const {SafeString} = require('../services/handlebars');
const errors = require('@tryghost/errors');
const tpl = require('@tryghost/tpl');

View file

@ -10,7 +10,7 @@
// Block helper: `{{#author}}{{/author}}`
// This is the default handlebars behaviour of dropping into the author object scope
const {urlService} = require('../services/proxy');
const {SafeString, escapeExpression, hbs, templates} = require('../services/rendering');
const {SafeString, escapeExpression, hbs, templates} = require('../services/handlebars');
const isString = require('lodash/isString');
const builtInHelpers = hbs.handlebars.helpers;

View file

@ -7,7 +7,7 @@
//
// Note that the standard {{#each authors}} implementation is unaffected by this helper.
const {urlService} = require('../services/proxy');
const {SafeString, escapeExpression, templates} = require('../services/rendering');
const {SafeString, escapeExpression, templates} = require('../services/handlebars');
const isString = require('lodash/isString');
const {utils} = require('@tryghost/helpers');

View file

@ -2,7 +2,7 @@
// Usage: `{{body_class}}`
//
// Output classes for the body element
const {SafeString} = require('../services/rendering');
const {SafeString} = require('../services/handlebars');
// We use the name body_class to match the helper for consistency
module.exports = function body_class(options) { // eslint-disable-line camelcase

View file

@ -6,7 +6,7 @@
//
// Defaults to class="cancel-subscription-link" errorClass="cancel-subscription-error" cancelLabel="Cancel subscription" continueLabel="Continue subscription"
const {labs} = require('../services/proxy');
const {templates} = require('../services/rendering');
const {templates} = require('../services/handlebars');
const errors = require('@tryghost/errors');
const tpl = require('@tryghost/tpl');

View file

@ -1,4 +1,4 @@
const {SafeString} = require('../services/rendering');
const {SafeString} = require('../services/handlebars');
module.exports = function concat(...args) {
const options = args.pop();

View file

@ -10,7 +10,7 @@
//
// Dev flag feature: In case of restricted content access for member-only posts, shows CTA box
const {templates, hbs, SafeString} = require('../services/rendering');
const {templates, hbs, SafeString} = require('../services/handlebars');
const downsize = require('downsize');
const _ = require('lodash');
const createFrame = hbs.handlebars.createFrame;

View file

@ -3,7 +3,7 @@
//
// Formats a date using moment-timezone.js. Formats published_at by default but will also take a date as a parameter
const {SafeString} = require('../services/rendering');
const {SafeString} = require('../services/handlebars');
const moment = require('moment-timezone');
const _ = require('lodash');

View file

@ -4,7 +4,7 @@
//
// Returns URI encoded string
const {SafeString} = require('../services/rendering');
const {SafeString} = require('../services/handlebars');
module.exports = function encode(string, options) {
const uri = string || options;

View file

@ -5,7 +5,7 @@
//
// Defaults to words="50"
const {SafeString} = require('../services/rendering');
const {SafeString} = require('../services/handlebars');
const {metaData} = require('../services/proxy');
const _ = require('lodash');
const getMetaDataExcerpt = metaData.getMetaDataExcerpt;

View file

@ -3,7 +3,7 @@
//
// Output a url for a facebook username
const {socialUrls} = require('../services/proxy');
const {localUtils} = require('../services/rendering');
const {localUtils} = require('../services/handlebars');
// We use the name facebook_url to match the helper for consistency:
module.exports = function facebook_url(username, options) { // eslint-disable-line camelcase

View file

@ -3,7 +3,7 @@
//
// Block helper designed for looping through posts
const {checks} = require('../services/data');
const {hbs} = require('../services/rendering');
const {hbs} = require('../services/handlebars');
const _ = require('lodash');
const logging = require('@tryghost/logging');

View file

@ -2,7 +2,7 @@
// Usage: `{{#get "posts" limit="5"}}`, `{{#get "tags" limit="all"}}`
// Fetches data from the API
const {config, api, prepareContextResource} = require('../services/proxy');
const {hbs} = require('../services/rendering');
const {hbs} = require('../services/handlebars');
const logging = require('@tryghost/logging');
const errors = require('@tryghost/errors');

View file

@ -3,7 +3,7 @@
//
// Outputs scripts and other assets at the bottom of a Ghost theme
const {settingsCache} = require('../services/proxy');
const {SafeString} = require('../services/rendering');
const {SafeString} = require('../services/handlebars');
const _ = require('lodash');
// We use the name ghost_foot to match the helper for consistency:

View file

@ -3,7 +3,7 @@
//
// Outputs scripts and other assets at the top of a Ghost theme
const {metaData, settingsCache, config, blogIcon, urlUtils, labs} = require('../services/proxy');
const {escapeExpression, SafeString} = require('../services/rendering');
const {escapeExpression, SafeString} = require('../services/handlebars');
// BAD REQUIRE
// @TODO fix this require

View file

@ -12,7 +12,7 @@
// Language tags in HTML and XML
// https://www.w3.org/International/articles/language-tags/
const {SafeString} = require('../services/rendering');
const {SafeString} = require('../services/handlebars');
module.exports = function lang(options) {
const locale = options.data.site.locale;

View file

@ -1,6 +1,6 @@
// # link helper
const {config} = require('../services/proxy');
const {SafeString, localUtils} = require('../services/rendering');
const {SafeString, localUtils} = require('../services/handlebars');
const _ = require('lodash');
const errors = require('@tryghost/errors');

View file

@ -1,6 +1,6 @@
// # link_class helper
const {config} = require('../services/proxy');
const {SafeString, localUtils} = require('../services/rendering');
const {SafeString, localUtils} = require('../services/handlebars');
const _ = require('lodash');
const errors = require('@tryghost/errors');

View file

@ -1,4 +1,4 @@
const {SafeString} = require('../services/rendering');
const {SafeString} = require('../services/handlebars');
const logging = require('@tryghost/logging');
const tpl = require('@tryghost/tpl');

View file

@ -1,7 +1,7 @@
// ### Navigation Helper
// `{{navigation}}`
// Outputs navigation menu of static urls
const {SafeString, templates, hbs} = require('../services/rendering');
const {SafeString, templates, hbs} = require('../services/handlebars');
const errors = require('@tryghost/errors');
const tpl = require('@tryghost/tpl');

View file

@ -1,7 +1,7 @@
// ### Pagination Helper
// `{{pagination}}`
// Outputs previous and next buttons, along with info about the current page
const {templates, hbs} = require('../services/rendering');
const {templates, hbs} = require('../services/handlebars');
const errors = require('@tryghost/errors');
const tpl = require('@tryghost/tpl');

View file

@ -9,7 +9,7 @@
// The 2nd argument is the string that will be output if the variable's value is 0
// The 3rd argument is the string that will be output if the variable's value is 1
// The 4th argument is the string that will be output if the variable's value is 2+
const {SafeString} = require('../services/rendering');
const {SafeString} = require('../services/handlebars');
const errors = require('@tryghost/errors');
const tpl = require('@tryghost/tpl');

View file

@ -2,7 +2,7 @@
// Usage: `{{post_class}}`
//
// Output classes for the body element
const {SafeString} = require('../services/rendering');
const {SafeString} = require('../services/handlebars');
// We use the name post_class to match the helper for consistency:
module.exports = function post_class() { // eslint-disable-line camelcase

View file

@ -3,7 +3,7 @@
// `{{#prev_post}}<a href ="{{url}}>previous post</a>{{/prev_post}}'
// `{{#next_post}}<a href ="{{url absolute="true">next post</a>{{/next_post}}'
const {api} = require('../services/proxy');
const {hbs} = require('../services/rendering');
const {hbs} = require('../services/handlebars');
const {checks} = require('../services/data');
const logging = require('@tryghost/logging');

View file

@ -4,7 +4,7 @@
// Returns a string of the products with access to the post.
// By default, products are separated by commas.
const {labs} = require('../services/proxy');
const {SafeString} = require('../services/rendering');
const {SafeString} = require('../services/handlebars');
const isString = require('lodash/isString');

View file

@ -11,7 +11,7 @@
// Returns estimated reading time for post
const {checks} = require('../services/data');
const {SafeString} = require('../services/rendering');
const {SafeString} = require('../services/handlebars');
const {readingTime: calculateReadingTime} = require('@tryghost/helpers');

View file

@ -10,7 +10,7 @@
// because often other helpers need that (t) returns a string to be able to work as subexpression; e.g.:
// {{tags prefix=(t " on ")}}
const {themeI18n} = require('../services/rendering');
const {themeI18n} = require('../services/handlebars');
module.exports = function t(text, options) {
const bindings = {};

View file

@ -6,7 +6,7 @@
//
// Note that the standard {{#each tags}} implementation is unaffected by this helper
const {urlService} = require('../services/proxy');
const {SafeString, escapeExpression, templates} = require('../services/rendering');
const {SafeString, escapeExpression, templates} = require('../services/handlebars');
const isString = require('lodash/isString');
const ghostHelperUtils = require('@tryghost/helpers').utils;

View file

@ -4,7 +4,7 @@
// Returns a string of the tiers with access to the post.
// By default, tiers are separated by commas.
const {labs} = require('../services/proxy');
const {SafeString, escapeExpression} = require('../services/rendering');
const {SafeString, escapeExpression} = require('../services/handlebars');
const isString = require('lodash/isString');

View file

@ -3,7 +3,7 @@
//
// Overrides the standard behaviour of `{[title}}` to ensure the content is correctly escaped
const {SafeString, escapeExpression} = require('../services/rendering');
const {SafeString, escapeExpression} = require('../services/handlebars');
module.exports = function title() {
return new SafeString(escapeExpression(this.title || ''));

View file

@ -3,7 +3,7 @@
//
// Output a url for a twitter username
const {socialUrls} = require('../services/proxy');
const {localUtils} = require('../services/rendering');
const {localUtils} = require('../services/handlebars');
// We use the name twitter_url to match the helper for consistency:
module.exports = function twitter_url(username, options) { // eslint-disable-line camelcase

View file

@ -5,7 +5,7 @@
// `absolute` flag outputs absolute URL, else URL is relative
const {metaData} = require('../services/proxy');
const {SafeString} = require('../services/rendering');
const {SafeString} = require('../services/handlebars');
const logging = require('@tryghost/logging');
const sentry = require('../../shared/sentry');
const errors = require('@tryghost/errors');

View file

@ -1,5 +1,5 @@
/**
* This is a loose concept of a frontend rendering framework
* This is a loose concept of a frontend handlebars toolkit
* Note: everything here gets deep-required from the theme-engine
* This indicates that the theme engine is a set of services, rather than a single service
* and could do with a further refactor.
@ -17,6 +17,7 @@ module.exports = {
templates: require('./theme-engine/handlebars/template'),
// Theme i18n
// @TODO: this should live somewhere else...
themeI18n: require('./theme-engine/i18n'),
// TODO: these need a more sensible home

View file

@ -2,7 +2,7 @@ const Promise = require('bluebird');
const errors = require('@tryghost/errors');
const logging = require('@tryghost/logging');
const {hbs} = require('../rendering');
const {hbs} = require('../handlebars');
// Register an async handlebars helper for a given handlebars instance
function asyncHelperWrapper(hbsInstance, name, fn) {

View file

@ -2,8 +2,8 @@
const settingsCache = require('../../shared/settings-cache');
const config = require('../../shared/config');
// Require from the rendering framework
const {SafeString} = require('./rendering');
// Require from the handlebars framework
const {SafeString} = require('./handlebars');
module.exports = {
/**

View file

@ -1,7 +1,7 @@
const should = require('should');
const sinon = require('sinon');
const Promise = require('bluebird');
const {SafeString} = require('../../../../core/frontend/services/rendering');
const {SafeString} = require('../../../../core/frontend/services/handlebars');
// Stuff we are testing
const get = require('../../../../core/frontend/helpers/get');

View file

@ -1,7 +1,7 @@
const should = require('should');
const testUtils = require('../../../../../utils');
const helpers = require('../../../../../../core/frontend/services/routing/helpers');
const {SafeString} = require('../../../../../../core/frontend/services/rendering');
const {SafeString} = require('../../../../../../core/frontend/services/handlebars');
describe('Unit - services/routing/helpers/format-response', function () {
let posts;

View file

@ -1,6 +1,6 @@
const should = require('should');
const errors = require('@tryghost/errors');
const {hbs, templates} = require('../../../../../../core/frontend/services/rendering');
const {hbs, templates} = require('../../../../../../core/frontend/services/handlebars');
describe('Helpers Template', function () {
it('can execute a template', function () {